I am developing an application is room booking. First I want to show the available rooms to the user based on his city and fromdate and todate. For this I have a table tbl_room with columns like id, room_name, city, fromdate, todate and so on.
I am trying to write a query based on fromdate and todate and city for showing available rooms from my table.
My query looks like this :
select
rooms, price, name, persons_capacity
from
tbl_room
where
city = 'xxxx'
and fromdate between 'yyyy-mm-dd' and 'yyyy-mm-dd'
But this returns wrong results because I am not checking todate here.
How can I use todate in my query for checking availability rooms?
Thanks.