-2

I want to run a query where you select every data between date1 to date2 that has status of Confirmed or Reserved grouped by status.

But the code I'm trying,

select * from reservation where (date(bdate) between '2013-2-4' and '2013-2-8') and status='Reserved' or status='Confirmed' order by status

doesn't seem to work.

I need to fetch the data within the date range only that has either Confirmed or Reserved status. Please help me. Thanks.

John Woo
  • 258,903
  • 69
  • 498
  • 492
xjshiya
  • 915
  • 7
  • 16
  • 44

2 Answers2

1
select *
from   reservation 
where  date(bdate) between '2013-2-4' and '2013-2-8' and 
       status IN ('Reserved','Confirmed')
order  by status
John Woo
  • 258,903
  • 69
  • 498
  • 492
0

You could use query like this

select *
from reservation
where date(bdate) between '2013-2-4' and '2013-2-8'
    and (status = 'Reserved'
      or status = 'Confirmed')
order by status
Muhammad Raheel
  • 19,823
  • 7
  • 67
  • 103