I have tried your solution but I had to modify it a bit. I think you meant something like this:
SELECT rooms.roomid, rooms.roomname
FROM rooms
LEFT JOIN booking ON rooms.roomid = booking.roomid
WHERE ( booking.startdate IS NULL AND booking.enddate IS NULL )
OR ( booking.startdate < $startdate AND booking.startdate < $enddate )
OR ( booking.enddate > $startdate AND booking.enddate > $enddate )
That means either both requested dates is before the startdate in db OR later than the enddate in db.
This works fine unless there are e.g. 2 records with the SAME roomid in the booking table, and one is overlapping with the requested dates (that is not available) and the other is not. In this case it will select the one which dates are not overlapping with the requested dates and list the room as available!
That's why I was thinking about an other logic, namely to select from bookings the rooms that are not available (dates are overlapping with requested dates), and then somehow exclude these from all the rooms in the table rooms.
What do you think? What sql query should I use in this case?
Thanks