I have a problem in writing the sql to get the available rooms from the tables. my table structures are given below.
table : booking
boo
This should do it; if there is a reservation that does not end before or start after the reservation we want, the room is considered busy.
SELECT r.room_id
FROM rooms r
WHERE r.room_id NOT IN (
SELECT b.room_id FROM bookings b
WHERE NOT (b.end_datetime < '2012-09-14T18:00'
OR
b.start_datetime > '2012-09-21T09:00'))
ORDER BY r.room_id;
SQLFiddle here.