SELECT *
FROM room
WHERE room_no NOT IN
(
SELECT room_no
FROM booking
WHERE check_outdate >= @req_fdate
AND check_indate <= @red_tdate
)
AND room_no NOT IN
(
SELECT room_no
FROM reservation
WHERE check_outdate >= @req_fdate
AND check_indate <= @red_tdate
)
Perhatikan urutan atau argumennya:@req_fdate
ini kencan pertama di sini (dari ), @req_tdate
adalah tanggal terakhir (sampai ).
Untuk memeriksa ketersediaan dari Aug 16
ke Aug 19
, gunakan ini:
SELECT *
FROM room
WHERE room_no NOT IN
(
SELECT room_no
FROM booking
WHERE check_outdate >= '2010-08-16'
AND check_indate <= '2010-08-19'
)
AND room_no NOT IN
(
SELECT room_no
FROM reservation
WHERE check_outdate >= '2010-08-16'
AND check_indate <= '2010-08-19'
)