我正在用 php 和 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 |ss@gmail.com| xy | AC | R1 |5000 | 2012-12-26|2012-12-30
2 |satyawan | lahu@gmail.com|unr | Non A/C | R6 | 20002012-01-01|2012-12-07
3 |satyawan | lahu@gmail.com|unr | Non A/C | R8 | 2013-01-01 |2013-01-10
4 |satyawan | lahu@gmail.com|unr | Non A/C | R9 | 2013-01-10 |2013-01-16
5 |satyawan | lahu@gmail.com|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)
但我只想要未预订房间的数据。如果房间已经被预订,那么它必须表明这个房间在这个日期已经被预订了。
我对此一无所知。