I have an availability table ind Mysql as follows:
id
room_id int(11)
avail_date date
For each room, there is a row for every date it is availa
You want something like this:
select room_id
from availability a
where avail_date between $start and $end
group by room_id
having count(*) = datediff($end, $start) + 1;
The having
clause is counting the number of rows during that period to see if it matches the number of days you need. This is "inclusive" logic, so if $start = $end
, then it assumes you need the room on that date.