I am trying to show the free rooms in my hotel by start date and end date
When I use This code it only shows me the room wich appear in reservation but it doeen't shows me the room which were never reserved.
SELECT room.RoomID,room.Room_Type_ID,room.Room_number,room.NumberofSpots,
res.Data_Check_in,res.Data_Check_out FROM
dbo.Reservation res JOIN dbo.Room room ON room.RoomID=res.Room_ID
WHERE NOT(res.Data_Check_in<=@p_StartData AND res.Data_Check_out>=@p_EndData)
When i use this code its shows me all the rooms even those reserved:
SELECT DISTINCT r.*
FROM dbo.Room r LEFT JOIN dbo.Reservation res ON r.RoomID=res.Room_ID
AND NOT(res.Data_Check_in<='2012-05-07' AND res.Data_Check_out>='2012-06-13')
AND res.Cancel=0
What should i modify to get all the rooms without those which are reserved for selected date?