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