tags:

views:

30

answers:

2

hi how can i use more than one 'between' clause in mysql query ? like if i want to select students having height between 20 and 25 and weight between 50 and 70..

thanks in advance

tismon

+2  A: 
WHERE height BETWEEN 20 AND 25 AND weight BETWEEN 50 AND 70
reko_t
maybe you should use the and operator
Eineki
Should be `... AND weight BETWEEN 50 AND 70`
Péter Török
No it shouldn't. How can a value be between 20 and 25, and 50 and 70 at the same time? If my height is 23, it can't be 62 at the same time.
reko_t
...HEIGHT between 20 and 25 and WEIGHT between 50 and 70..
tismon
Oops, I misread the question. I thought he wanted height for both, but I see that he wanted weight for the second criteria now. Fixed the answer.
reko_t
A: 

WHERE height BETWEEN 20 AND 25 AND weight BETWEEN 50 AND 70

Bear in mind that your condition being applied to each row one-by-one, not to "whole table at once".

Col. Shrapnel