我想运行一个查询,您可以在其中选择 date1 到 date2 之间的所有数据,其状态为已确认或保留< / em>按状态分组。
但是我正在尝试的代码,
select * from reservation where (date(bdate) between '2013-2-4' and '2013-2-8') and status='Reserved' or status='Confirmed' order by status
似乎不起作用。
我需要仅在具有已确认或保留状态的日期范围内获取数据。请帮我。感谢。
答案 0 :(得分:1)
select *
from reservation
where date(bdate) between '2013-2-4' and '2013-2-8' and
status IN ('Reserved','Confirmed')
order by status
答案 1 :(得分:0)
你可以使用这样的查询
select *
from reservation
where date(bdate) between '2013-2-4' and '2013-2-8'
and (status = 'Reserved'
or status = 'Confirmed')
order by status