Search database from list

Discussion in 'ASP .Net' started by =?Utf-8?B?TWljaGFlbA==?=, Jul 10, 2007.

  1. 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
     
    =?Utf-8?B?TWljaGFlbA==?=, Jul 10, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?TWljaGFlbA==?=

    David Wier Guest

    Take a look at this 2 part tutorial on parameterized queries:
    http://www.aspnet101.com/aspnet101/tutorials.aspx?id=1

    It covers using the 'like' operator with SQL statements

    --
    David Wier
    MVP/ASPInsider
    http://aspnet101.com
    http://iWritePro.com



    "Michael" <> wrote in message
    news:...
    > 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
     
    David Wier, Jul 10, 2007
    #2
    1. Advertising

  3. On Jul 10, 10:36 pm, Michael <>
    wrote:
    > 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
     
    Alexey Smirnov, Jul 10, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?=

    Google search result like site search!! How?

    =?Utf-8?B?TGFrc2htaSBOYXJheWFuYW4uUg==?=, May 5, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    706
    Lucas Tam
    May 6, 2005
  2. Andy
    Replies:
    1
    Views:
    369
    Jack Klein
    Nov 25, 2003
  3. Anand Pillai

    String search vs regexp search

    Anand Pillai, Oct 12, 2003, in forum: Python
    Replies:
    10
    Views:
    611
    Anand Pillai
    Oct 15, 2003
  4. mason66
    Replies:
    0
    Views:
    432
    mason66
    Jul 27, 2006
  5. Abby Lee
    Replies:
    5
    Views:
    447
    Abby Lee
    Aug 2, 2004
Loading...

Share This Page