[英]MYSql query to find booking available in hotel management system
I am working on a sample project "Hotel Management System". 我正在研究一个示例项目“酒店管理系统”。 Here I have created two tables. 在这里,我创建了两个表。
tbl_room tbl_room
| | roomid | 室号 | roomno | 室号
and 和
tbl_booking tbl_booking
| | bookingid | bookingid | roomid | 室号 | checkin | 签到 | checkout | 结帐 |
I have created a query I get $indate and $outdate from the form. 我创建了一个查询,我从表单中获取$ indate和$ outdate。
$sql="SELECT roomid from tbl_room
where tbl_room.roomid not in (select roomid from tbl_booking where
checkout>'$indate' )";
This query doesn't work. 此查询不起作用。 It only checks the checkout date and i cannot book the previous date. 它只检查结帐日期,而我不能预定以前的日期。
$sql="SELECT * FROM tbl_room WHERE roomid not in (SELECT b.roomid FROM tbl_booking b
where(b.checkout BETWEEN '$checkin' and '$checkout') and
(b.checkin BETWEEN '$checkin' and '$checkout'))";
Finally, This query Worked. 最后,此查询成功。
检查此查询,它检查给定的日期范围在预订表中是否有条目并将其从room_master中排除。
$sql="SELECT * FROM tbl_room WHERE roomid not in (SELECT b.roomid FROM tbl_booking b where(b.checkout BETWEEN '$checkin' and '$checkout') and (b.checkin BETWEEN '$checkin' and '$checkout'))";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.