views:

19

answers:

1

I'm trying to do the following, If a user the enters the term "IP Address Text" into my search box then I want the following SQL to be generated:

SELECT *
FROM tblComments
WHERE tblComments.Text LIKE '%IP%' OR tblComments.Text LIKE '%Address%' OR tblComments.Text LIKE '%Text%'

Obviously the number of words entered is going to be different each time. I have tried a for each loop in LinqToSql adding multiple where clauses but this uses "AND" instead of "OR"

Any idea how to accomplish this?

A: 

You may want to read up on full text searching as an alternative to what you're trying to accomplish here. Searching for '%word%' will never perform well as the query cannot use an index.

Joe Stefanelli
Thanks, I've ended up going down that route now, although I've only implemented it in it's simplest form.
Gazeth