Skip to content
Advertisement

SQL : select values between multiple ranges

I have a table like the one below…

ID    Price
==== ======
1    1000
2    2000
3    4000
4    5000

Now I need a query to select values between 500 and 1500 And between 2500 and 4500. i.e. like using two between in a single select query…

is it possible?

output should be:

ID    Price
==== ======
1    1000
3    4000

Advertisement

Answer

select id, price
from tablename
where price between 500 and 1500
   or price between 2500 and 4500
2 People found this is helpful
Advertisement