简体   繁体   English

PHP的MySQL的选择结果,没有在两个日期之间重新记录

[英]php mysql select result that has no recored between two dates

I have a table called "bookings" with rooms id & booking date 我有一张名为“ bookings”的表格,其中包含房间编号和预订日期

as

ID        Date
1         2018-04-20
1         2018-04-21
2         2018-04-20
4         2018-04-01
4         2018-04-02
4         2018-04-09

In html the user input the check in date and checkout date 在html中,用户输入签入日期和签出日期

what i want to do is find all rooms id's that has no dates equal or in between the check in and check out input dates... 我想做的是找到所有没有日期等于或介于入住和退房输入日期之间的房间ID ...

for example if user input check in as: 2018-04-19 and checkout: 2018-04-21 then result should be : 4 例如,如果用户输入的签入日期为:2018-04-19,结帐日期为:2018-04-21,则结果应为:4

how can i do this ? 我怎样才能做到这一点 ?

您可以使用NOT BETWEEN

SELECT * FROM `bookings` WHERE `date` NOT BETWEEN ? AND ?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM