Hi,
If I got ur question correctly, U r looking for matching words in table1 and table2 on a common colum.
U can use same Inner join with LIKE operator. lIKE OPERATOR CAN BE USED IN Inner Join colum itself or using a Where condition
SELECT TABLE1.NAME,TABLE2.NAME FROM TABLE1 INNER JOIN TABLE2
ON TABLE1.ID = TABLE2.ID
WHERE TABLE2.NAME LIKE '%'+ TABLE1.NAME + '%'
ORDER BY TABLE1.NAME
SELECT TABLE1.NAME,TABLE2.NAME FROM TABLE1 INNER JOIN TABLE2
ON TABLE1.ID = TABLE2.ID
WHERE TABLE2.ADDRESS LIKE '%'+ TABLE1.ADDRESS + '%'
ORDER BY TABLE1.ADDRESS
U can use '%' both sides to compare. There are some other ways e.g PatIndex, CharIndex etc.
I feel u should use the '%' both sides while comparing, It match the pattern.
Hope this helps.
B. Anant
|