user2186465
user2186465

Reputation: 197

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

Upvotes: 5

Views: 17299

Answers (1)

jarlh
jarlh

Reputation: 44805

select id, price
from tablename
where price between 500 and 1500
   or price between 2500 and 4500

Upvotes: 11

Related Questions