I have the following problem: A reservation has a client and a room associated with it. When creating a reservation, I have to fill in some fields (such as customer name, date of entry, date of departure and the room where you will be staying).
Room selection is done through a dropdownlist that shows all rooms created. The problem is this same, I do not want to show all the rooms created, but rather, all the rooms available, ie those that do not have reservations on the date of creation of the reservation.
The query I've assembled so far is this:
SELECT Quarto.ID_Quarto FROM Quarto
LEFT OUTER JOIN Reserva ON Quarto.ID_Quarto = Reserva.ID_Quarto
WHERE DataEntrada > GETDATE()
And DataSaida < GETDATE()
OR Reserva.ID_Quarto IS NULL