我在PHP和MySQL 做酒店預訂系統的項目中,我創建的房間桌子,低於如何在酒店預訂系統中獲取unbook房間的準確mysql查詢?
room_no| roo_id | room_type
D1 | 1 | Deluxe
R1 | 2 | AC
R2 | 3 | Non Ac
C1 | 4 | Cottage
此表是關於房代表的酒店客房總數。
這是customer_booking表,
customer_id | Cust_name | email | Address | room_type | room_no| cost|check_in | check_out
1 | satyawan |[email protected]| xy | AC | R1 |5000 | 2012-12-26|2012-12-30
2 |satyawan | [email protected]|unr | Non A/C | R6 | 20002012-01-01|2012-12-07
3 |satyawan | [email protected]|unr | Non A/C | R8 | 2013-01-01 |2013-01-10
4 |satyawan | [email protected]|unr | Non A/C | R9 | 2013-01-10 |2013-01-16
5 |satyawan | [email protected]|unr | Non A/C | R6 | 2013-01-01 |2013-01-20
我已經燒上的未結算房間類型的數據都該表的連接查詢。查詢低於
SELECT *
FROM rooms
LEFT JOIN customer_booking
ON customer_booking.room_no = rooms.room_no
WHERE customer_booking.client_id IS NULL
OR (customer_booking.check_out >= 2013-01-01
AND customer_booking.check_in >= 2013-01-10)
OR (customer_booking.check_out <= 2013-01-01
AND customer_booking.check_out <= 2013-01-10)
但我只想要沒有預訂房間的數據。 如果房間已經預訂,那麼它必須顯示這個房間已經在這個日期預定。
我無法得知它。
非常接近......他正在尋找第1至第10個入住範圍,在2013/10/10之間加入/出,你應該很好。 – DRapp
@DRapp我修復了這個查詢。謝謝 – valex