Availability, always a head scratcher.
Reverse the logic, instead of looking to see if the room is free, look to see if it's already booked.
Select * from Bookings Where RoomNumber= 10
and (CheckInDate between '2009-01-04' and '2009-01-06') Or (CheckOutDate between '2009-01-04' and '2009-01-06')
That would say there are no bookings on teh 2/1/2009 though, so you need
Select * from Bookings Where RoomNumber= 10
and (CheckInDate between '2009-01-04' and '2009-01-06') Or (CheckOutDate between '2009-01-04' and '2009-01-06')
Or ('2009-01-04' between CheckInDate And CheckOutDate) Or ('2009-01-06' between CheckInDate And CheckOutDate)
You might find some mileage in a calendar table,
Room Date, AvailableYorN
Then you would have
10 1/1/2009 N
10 2/1/2009 N
10 3/1/2009 N
10 4/1/2009 Y
10 5/1/2009 Y
10 6/1/2009 Y
Then you check query becomes
Select * From Available Where Room = 10 and RoomDate Between SomeCheckIn and SomeCheckOut and availablyYN = N
Building the table is a bit of work in the booking and cancellation operations, but you can do things like add another column, and take the room out for refurbishment, have no rooms on holidays e.g. Xmas.
Stick a booking number on it, so you can say who has/had it booked. Look for all available rooms in a period....