Between value in query
Posted: Wed Nov 25, 2009 6:25 pm
Still learning, but need some help.
I want to create a form with a number of price ranges, where the results can be included in a query. For instance, checkbox 1 will be between 10 and 20, checkbox 2 will be between 20 and 30, etc.
I have been able to parse the form results, but am coming up with a problem when I try to put the values in a query. It works OK if one range is selected, but fails when two ranges are passed on. It doesn't seem to like running two between conditions in the query. For example;
Don't take the code too literally, but it gives you an idea of what I'm trying to achieve. It appears that you cannot put two BETWEEN conditions on the same field. Is this true, and if so, any suggestions on how to get around it.
Any experts out there that can point me in the right direction? Your help would be greatly appreciated.
I want to create a form with a number of price ranges, where the results can be included in a query. For instance, checkbox 1 will be between 10 and 20, checkbox 2 will be between 20 and 30, etc.
I have been able to parse the form results, but am coming up with a problem when I try to put the values in a query. It works OK if one range is selected, but fails when two ranges are passed on. It doesn't seem to like running two between conditions in the query. For example;
Code: Select all
select * from products WHERE price BETWEEN '10' AND '20' AND price BETWEEN '30' AND '40'Any experts out there that can point me in the right direction? Your help would be greatly appreciated.