Search question?

Discussion in 'ASP .Net' started by =?Utf-8?B?UnVkeQ==?=, May 26, 2005.

  1. Hello all!

    I posted this question on the SQL boards, got some great answers, but I
    thought I would also try here, since I'm using asp.net/vb.net.
    I'll try to lay this out a simple as possible. I think before I was
    approaching it the wrong way.
    I have 3 ddl's that have values from my database. ddlSize, ddlColor and
    ddlStyle.
    If a user wants to search for a product, they select the following, "Small,
    Red, Sportsman". So all the products that match this will show up.
    But if the user selected "Small, Red, and then 'Any' from ddl style. It
    should show all products that are Red and Small, but all Styles. Or if all
    three were selected "Any", then it should show everything.
    So my question is how can I write my SQL to say "SELECT ProductName AS
    FROM ProdTbl
    WHERE Color = *"
    I know I can't use *, it doen't work. So I just want if "Any" is selected,
    it will pick everthing.
    Or maybe there is a beter way to do this. I'm thinking about job sites that
    have search engines, select any job, or all job, or all locations. Giving the
    user the ability to see all the products, or maybe to see all red products.

    I hope this make sence, thank for your help!!

    Rudy
     
    =?Utf-8?B?UnVkeQ==?=, May 26, 2005
    #1
    1. Advertising

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

    Ben Guest

    I wouldn't use a where condition if 'any' is the selected option. If you
    must, you could do something cheesy like Color = blah OR 1 = 1...


    "Rudy" <> wrote in message
    news:...
    > Hello all!
    >
    > I posted this question on the SQL boards, got some great answers, but I
    > thought I would also try here, since I'm using asp.net/vb.net.
    > I'll try to lay this out a simple as possible. I think before I was
    > approaching it the wrong way.
    > I have 3 ddl's that have values from my database. ddlSize, ddlColor and
    > ddlStyle.
    > If a user wants to search for a product, they select the following,
    > "Small,
    > Red, Sportsman". So all the products that match this will show up.
    > But if the user selected "Small, Red, and then 'Any' from ddl style. It
    > should show all products that are Red and Small, but all Styles. Or if all
    > three were selected "Any", then it should show everything.
    > So my question is how can I write my SQL to say "SELECT ProductName AS
    > FROM ProdTbl
    > WHERE Color = *"
    > I know I can't use *, it doen't work. So I just want if "Any" is selected,
    > it will pick everthing.
    > Or maybe there is a beter way to do this. I'm thinking about job sites
    > that
    > have search engines, select any job, or all job, or all locations. Giving
    > the
    > user the ability to see all the products, or maybe to see all red
    > products.
    >
    > I hope this make sence, thank for your help!!
    >
    > Rudy
     
    Ben, May 26, 2005
    #2
    1. Advertising

  3. Hi Rudy,

    If you want 'any color', it should look like

    SELECT ProductName FROM ProdTbl WHERE Color LIKE '%'

    HTH

    Elton Wang






    "Rudy" wrote:

    > Hello all!
    >
    > I posted this question on the SQL boards, got some great answers, but I
    > thought I would also try here, since I'm using asp.net/vb.net.
    > I'll try to lay this out a simple as possible. I think before I was
    > approaching it the wrong way.
    > I have 3 ddl's that have values from my database. ddlSize, ddlColor and
    > ddlStyle.
    > If a user wants to search for a product, they select the following, "Small,
    > Red, Sportsman". So all the products that match this will show up.
    > But if the user selected "Small, Red, and then 'Any' from ddl style. It
    > should show all products that are Red and Small, but all Styles. Or if all
    > three were selected "Any", then it should show everything.
    > So my question is how can I write my SQL to say "SELECT ProductName AS
    > FROM ProdTbl
    > WHERE Color = *"
    > I know I can't use *, it doen't work. So I just want if "Any" is selected,
    > it will pick everthing.
    > Or maybe there is a beter way to do this. I'm thinking about job sites that
    > have search engines, select any job, or all job, or all locations. Giving the
    > user the ability to see all the products, or maybe to see all red products.
    >
    > I hope this make sence, thank for your help!!
    >
    > Rudy
     
    =?Utf-8?B?RWx0b24gVw==?=, May 26, 2005
    #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:
    679
    Lucas Tam
    May 6, 2005
  2. Andy
    Replies:
    1
    Views:
    360
    Jack Klein
    Nov 25, 2003
  3. Anand Pillai

    String search vs regexp search

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

Share This Page