0
我正在嘗試設置酒店預訂系統並遇到問題。我們正在努力尋找在多天和幾個月內可以使用房間的地方。以下是我們目前正在使用的四個查詢,但管理員無法提前預訂,直到有一個房間沒有任何活動。任何幫助都會很棒。酒店預訂日曆預訂邏輯問題
$sql_statementxf1 = "Select * FROM Hotels
WHERE EXISTS (
Select * FROM cal_events
WHERE start_date >= $end_dated
AND cal_events.HotelID = Hotels.HotelID
ORDER BY start_date)
AND HotelID>0
AND Class != 'HO'
ORDER BY HotelBlock, HotelNumber";
$sql_statementxf = "Select * FROM Hotels
WHERE EXISTS (
Select * FROM cal_events
WHERE end_date >= $start_dated
AND cal_events.HotelID = Hotels.HotelID)
AND NOT EXISTS (
select * from cal_events
WHERE start_date=$start_dated
AND cal_events.HotelID = Hotels.HotelID)
AND HotelID>0
AND Class != 'HO'
ORDER BY HotelBlock, HotelNumber";
$sql_statementxf2 = "Select * FROM Hotels
WHERE NOT EXISTS (
Select * FROM cal_events
WHERE cal_events.HotelID = Hotels.HotelID)
AND HotelID>0
AND Class != 'HO'
ORDER BY HotelBlock, HotelNumber";
$sql_statementxf3 = "Select * FROM Hotels
WHERE EXISTS (
Select * FROM cal_events
WHERE start_date=$start_dated
AND end_date = $end_dated
AND CustomerID = $custid
AND PersonID != $personid
AND cal_events.HotelID = Hotels.HotelID)
AND HotelID>0
AND Class!='HO'
ORDER BY HotelBlock, HotelNumber";