Checking the availability of rooms

If a customer is currently checked into a room, what do you have in the checkout column? If it’s null, then you can use checkout is null for your query or modify that part as you deem fit.

select count(*) from room where roomtype="DeluxeRoom" and roomnumber not in (
select room.roomnumber from room, reservation, roomreserve where room.roomtype="DeluxeRoom" and roomreserve.roomnumber = room.roomnumber and roomreserve.reservationid = reservation.reservationid and checkout is null)

You might also add a checked_out flag to Reservation table, to make your query easier.

Browse More Popular Posts

Leave a Comment