Mysql
 sql >> Database >  >> RDS >> Mysql

Trova stanza libera (sistema di prenotazione)

Ecco una query che mostrerà le stanze NON GRATUITE per un intervallo di date:

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

Puoi usarlo con

select roomnumber from rooms where roomnumber not in (... as above ...)

per trovare le camere GRATIS