I need to check the available hotels and quantity of rooms available on the hotels for some duration(start_date and end_date.
I have a table test(id, date, qty, hotel_id). I need to access all the the hotel ids with some condition on qty (eg. qty>2) and date between two dates(for eg: the date field of the test table should have date value greater than the '2013-05-06' and end date less than '2013-05-10').
I tried this query:
select hotel_id
from test
where qty>2
and date between '2013-05-06' and '2013-05-10';
But, another condition is there must be all date between given dates. i.e. the date field should have all date date values: '2013-05-06', '2013-05-07', '2013-05-08', '2013-05-09', '2013-05-10' . If any of the above date is missing, then it should return empty resultset. And if all date are available with qty>2(let), then it should return list of hotel_ids.
How can it be done in a single MySQL query?