views:

21

answers:

1

Hi,

I am trying to find out whether I can do the following using joins instead of looping through each record.

Table1
------------
LastName
FirstName

Table2
-------------
UniqueId
LastName  (full text indexed)
FirstName (full text indexed)

for each record in table1, I am trying to find out if there are any matching records in table2.

Thanks, sridhar

A: 

Need more info like what you are joining on. If you are joining based on those fields you could do:

SELECT Table2.LastName, Table2.FirstName
FROM Table2 INNER JOIN Table1 t ON t.FirstName=Table2.FirstName
AND t.LastName = Table2.LastName

This should return all rows where data matches up in both tables.

Is this waht you need?

EDIT PORTION

If you want that try this:

SELECT * FROM Table_2 t2 INNER JOIN Table_1 t1
ON t2.lastname LIKE t1.lastname + '%' 

Modify to fit your needs.

JonH
No that's not what I want. If we do the above it will only return the exact matches. I want to do something like "where LastName in Table2 is like LastName in Table1"
Sridhar
SELECT * FROM Table_2 t2 INNER JOIN Table_1 t1ON t2.lastname LIKE t1.lastname + '%'
JonH
I am trying to use full text querying capabilities. I don't want to use "LIKE" since it is not efficient on large number of records.
Sridhar