SQL:选择多个范围之间的值

时间:2015-03-23 10:26:38

标签: mysql sql

我有一张如下表所示的表......

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

现在我需要一个查询来选择值between 500 and 1500between 2500 and 4500。即在单个选择查询中使用两个......

有可能吗?

输出应该是:

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

1 个答案:

答案 0 :(得分:7)

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