I don't know it is possible for u or not but putting some ideas:
Why don't you send the categories with your querystring to another page.
Check the category and according to that build the query ..
Something like
If category = 1 then
Sql = "select * from table where (Color = '" & Query1 & '" or '"
& Query2 & '") or (Format = '" & Query3 & '" or '" & Query4 & '")"
Elseif category = 2 then
Sql = "select * from table where (Color = '" & Query1 & '" or '"
& Query2 & '") AND (Format = '" & Query3 & '" or '" & Query4 & '")"
End if
-----Original Message-----
From: Justin Gilli [mailto:[Email Address Removed]
Sent: Friday, April 30, 2004 11:04 AM
To: LazyDBA.com Discussion
Subject: And/Or Problem
I have an asp app passing checkbox parameters to another page via
request.querystring to a SQL statement.
I build a recordset based on these variables.
The fields: Format and Color.
Example:
Sql = "select * from table where (Color = '" & Query1 & '" or '" &
Query2 & '") or (Format = '" & Query3 & '" or '" & Query4 & '")"
The problem I have is that if the user submits variables from different
categories such as Format and Color the string will return all items
that match these criteria rather then the specific results. This is
because I have "or" in this case. Changing to "and" gives me too few
results. I need to dynamically determine the and/or based on the
categories submitted.
I assume I will need to handle this somehow in a Stored Procedure.
Can anyone steer me in the right direction on this one?
Sincerely,
Justin
MS Sql Server LazyDBA home page