hello, i am not sure if this is the appropriate place to post this so admins feel free to move my thread if necessary.
i am trying to query using BETWEEN statements for comparing of integers. an example would be:
my sql query:
logically i would be getting and i would want to get
strangely i keep getting only
any idea how do i get the desired results? i have no control over 5, 20 or 6. they could be any random number.
i am trying to query using BETWEEN statements for comparing of integers. an example would be:
PHP:
id start_num end_num name
1 1 10 alan
2 11 23 bala
3 24 30 john
4 31 40 david
my sql query:
Code:
SELECT name FROM table
WHERE
(5 BETWEEN start_num AND end_num)
OR (20 BETWEEN start_num AND end_num)
OR (6 BETWEEN start_num AND end_num);
logically i would be getting and i would want to get
- alan
- bala
- alan
strangely i keep getting only
- alan
- bala
any idea how do i get the desired results? i have no control over 5, 20 or 6. they could be any random number.