Search database from list

G

Guest

Hello,
I know that this question might need to also be in the SQL forum, but I'm
not sure where I need to code this. So here it is.

I need to create a search textbox that allows users to type in multiple
words. Like if they wanted to search for "big red house". I want to return
all records that have either "big", "red" or "house" in them. How can I do
this dynamically?

Currently I just send to the database something like this:

SELECT DISTINCT *
FROM MyTable
WHERE (Description LIKE @Search)

But that only returns where description is like all search words together.
So I'm not sure if the change I'm gonna need to make is in my c# code or in
my stored procedure.

Thanks for you help
Michael
 
G

Guest

Hello,
I know that this question might need to also be in the SQL forum, but I'm
not sure where I need to code this. So here it is.

I need to create a search textbox that allows users to type in multiple
words. Like if they wanted to search for "big red house". I want to return
all records that have either "big", "red" or "house" in them. How can I do
this dynamically?

Currently I just send to the database something like this:

SELECT DISTINCT *
FROM MyTable
WHERE (Description LIKE @Search)

But that only returns where description is like all search words together.
So I'm not sure if the change I'm gonna need to make is in my c# code or in
my stored procedure.

Michael,

all what you need is a full-text search
http://msdn2.microsoft.com/en-us/library/ms142571.aspx

Once it's enabled the query will be like the one below

select * from MyTable
where contains (Description, @Search)

Hope it helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top