Search question?

G

Guest

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
 
B

Ben

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...
 
G

Guest

Hi Rudy,

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

SELECT ProductName FROM ProdTbl WHERE Color LIKE '%'

HTH

Elton Wang
(e-mail address removed)
 

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
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top