Searching a list of words in multiple columns Constraint : Each word must exist in one of them



Hi!

I have a requirement where I need to pass in the list of words (could
be separated by space) and then I need to find all the rows in SQL
which have each of these words in any of the 4 columns.

Table ContactDetail
columns addressLine1, addressLine2, Town, Country

It can have data like:
1. 32 Royal street, whateverlane, whatevertown, mycountry
2. cologne street, lane no. 5, anothertown, anothercountry
3, mycountry street, anotherlane, anothercountry

Now incase the user searches for 'whateverlane 32' only row 1 should
return.
Incase the user searches for 'mycountry' both rows 1 and 3 should
return.

Basically all the keywords entered must appear in a row in any of the
columns.

I have created a stored procedure which creates a temporary table of
these words. I think after this I need to make use of containstable,
but I am not clear on how.

Any help in this will be appreciated.

Thankx,
Rajat

.


Loading