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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top