酒店入住及退房时间为
表数据
check in check out room name
2018-09-17 11:00:00 2018-09-19 11:00:00 room 1
2018-09-18 11:00:00 2018-09-19 11:00:00 room 2注:标准入住及退房时间:上午11:00
如果我试着约会from 2018-09-17 11:00:00 to 2018-09-18 11:00:00,那么output for that date total booked should be 1. 1号房间已经订好了,2号房间应该是免费的。
我的疑问
SELECT * FROM transcationmaster WHERE checkin >= STR_TO_DATE('2018-09-17 11:00:00', '%Y-%m-%d %H:%i:%s') and checkout <= STR_TO_DATE('2018-09-18 11:00:00', '%Y-%m-%d %H:%i:%s') 如何在mysql中做到这一点?
提前感谢
发布于 2018-09-12 07:06:34
这只是重叠的范围问题。要查找与您自己的日期范围重叠的记录,请尝试以下查询:
SELECT *
FROM transactionmaster
WHERE '2018-09-17 11:00:00' < checkout AND '2018-09-18 11:00:00' > checkin;

https://stackoverflow.com/questions/52289144
复制相似问题