I started by asking this question I wish to Select all rows which contain any element from an array
And while my current question is almost identical, it serves a whole different purpose, and so I fear the answer may be different which would obscure the previous one, with that said.
I am working on a search engine type thing. I need to search a title stored in a database to see if it contains any of the words in the search textbox. I plan to then iterate through each of those rows, counting how many words match and ranking the results accordingly. I am sure this has been done many times by now. I just can’t seem to figure out how to do it without
select * from table
then sorting it in c#
You could try something like this:
The
%signs are the analogous to*in typical searches.To take the string and create this query for multiple words you could do something like this:
The spaces at the end of the strings are important, don’t forget those! Also, you’ll probably want to sanitize the string before you split it (remove extra punctuation, maybe even remove words like “a” or “the” or “to” etc.)