I've been racking my brain on how to do this for a while, and i know that some genius on this site will have the answer. Basically i'm trying to do this:
SELECT column
FROM table
WHERE [table].[column] LIKE string1
OR [table].[column] LIKE string2
OR [table].[column] LIKE string3...
for a list of search strings stored in a column of a table. Obviously I can't do a like statement for each string by hand because i want the table to be dynamic.
Any suggestions would be great. :D
EDIT:
I'm using MSSQL :(
Sounds like you are trying to do a fulltext search. MySQL has a tool for this:
http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html
In case of MSSQL some information is available at
http://msdn.microsoft.com/en-us/library/cc879300.aspx
Put the parameters (string1, string2, string3...) into a table (
Params
) thenJOIN
to the table usingLIKE
theJOIN
clause e.g.Make a sample Table_1:
To find all the Freds and Jos you code
What you'd like is a dynamic WHERE. You can achieve this by putting the wildcards in Table_2:
and performing the LIKE with an INNER JOIN:
Result: