Ето заявка, която ще покаже НЕБЕЗПЛАТНИ стаи за период от време:
select room from bookings where
(arrival<'2011-03-12' and departure>='2011-03-12') -- overlap at the end
OR (arrival<='2011-03-10' and departure>'2011-03-10') -- overlap at the start
OR (arrival>='2011-03-10' and departure<='2011-03-12') -- complete overlap
Можете да използвате това с
select roomnumber from rooms where roomnumber not in (... as above ...)
за да намерите БЕЗПЛАТНИ стаи