I have a problem in writing the sql to get the availables rooms from the tables.
My tables structures are given below.
Table Booking
ID | START_DATE | END_DATE
Table BookingRoom (Intermediate Table)
ID | BOOKING_ID |ROOM_ID
A Room can be linked to many bookings and a booking can contain many rooms
Table Room
Contains the ID room
I have Tried This but there is a probleme if a room is linked to 2 differents bookings in separate dates the comparaison will be maked with only the first booking id
SELECT DISTINCT r.ID FROM room AS r ,booking AS b,bookingroom AS br
WHERE r.ID = br.ID_ROOM
AND b.ID = br.ID_BOOKING
AND (
b.END_DATE < '05/14/2013'
OR b.START_DATE > '05/15/2013'
)
Can someone help me to write the SQL to get the available rooms between a checkin and checkout date.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…