For a booking system I have a table with rooms, arrival and departure.
Example data:
id | room | arrival | departure
---+------+------------+-----
You could also use the BETWEEN
comparison operator for this purpose. In this case you would do something like this:
SELECT r.id FROM room r WHERE r.id NOT IN
(
SELECT rb.room FROM room_booking rb WHERE
('2011-03-10' BETWEEN rb.arrival AND rb.departure) OR
('2011-03-12' BETWEEN rb.arrival AND rb.departure)
)