我在旅行CRS protal工作。对于酒店预订我想阻止酒店 取决于截止日期。
SELECT * FROM (`crs_service_supplier_details` as crs) JOIN `crs_service_room_type_detail` as Room ON `crs`.`service_apartment_id`=`Room`.`service_id` JOIN `crs_room_type` as crt ON `Room`.`room_type_id`=`crt`.`room_type_id` JOIN `crs_service_off_dates` as ccod ON `crs`.`service_apartment_id`=`ccod`.`co_service` WHERE `crs`.`city` like '%Chennai%' AND ('2016-10-27' NOT between ccod.cut_off_from AND ccod.cut_off_from) AND ('2016-10-28' NOT between ccod.cut_off_to AND ccod.cut_off_to) AND `Room`.`edate` > '2016-10-27' GROUP BY `crs`.`service_apartment_id`
这是查询,但问题是切入了两天
co_id co_service cut_off_from cut_off_to cut_off_release_days cut_off
1 1 2016-10-20 2016-10-22 0 2016-10-20
2 1 2016-10-27 2016-10-28 0 2016-10-28
如果我在2016-10-20
和2016-10-22
之间进行搜索,则会获得" 2016-10-27 and 2016-10-28
"并显示结果。
如果我在2016-10-27
和2016-10-28
之间进行搜索,则会获得" 2016-10-20 and 2016-10-22
"并显示结果。
它不会阻止任何系统的位置。请给出一些解决这个问题的想法?
答案 0 :(得分:0)
可能是你的查询不对。可能这会有所帮助,只需更改BETWEEN逻辑:
AND ('2016-10-27' NOT BETWEEN ccod.cut_off_from AND ccod.cut_off_to)
AND ('2016-10-28' NOT BETWEEN ccod.cut_off_to AND ccod.cut_off_from)
使用上述内容。
BETWEEN的原始代码没有意义:
AND ('2016-10-27' NOT BETWEEN ccod.cut_off_from AND ccod.cut_off_from)
AND ('2016-10-28' NOT BETWEEN ccod.cut_off_to AND ccod.cut_off_to)
因为它是在同一列之间进行的。