1
I have the following problem: A reservation has associated with you a client and a room. When creating a reservation, I have to fill in some fields (such as customer name, date of arrival, date of departure and the room where you will be staying).
The selection of the room is made through a dropdownlist that shows all the rooms created. The problem is this same, I do not want to show all the rooms created, but yes, all the rooms available, ie those who have no reservations at the date of creation of the reservation.
To query that 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
I didn’t understand that:
Aqueles que não tem reservas na data de criação da reserva.
. I could explain your question better?– Marconi
When I make a reservation... I have a room attribute ... in this attribute I have a dropdownlist that shows me all the rooms I have... whether they are occupied or not. What I intend is that if someone will now book room 1 and then someone else will book another room... in this dropdown list room 1 as it has already been occupied, it cannot appear on this dropdown list. I just want that room to appear again... when the date of departure is given ( check out)
– John
Is your Date field only filled in after the person leaves? I believe that what you need to use is not exists!
– Marconi
because my idea was... if you give the date of entry the room is reserved, if you give the date of exit, it is already free. Do you think that’s correct or do you have any better suggestions?
– John