gpt4 book ai didi

mysql - 使用 mySQL 查找今天的免费房间

转载 作者:行者123 更新时间:2023-12-01 00:14:35 25 4
gpt4 key购买 nike

如果在 mysql 表 RESERVATIONS 中有 RPOM_NUMBER、DATE_ARRIVAL 和 DATE_DEPARTED

如何找到今天可用的所有房间?

最佳答案

检查在特定时间可用的房间:

select RPOM_NUMBER
from RESERVATIONS r
group by RPOM_NUMBER
having not exists (
select *
from RESERVATIONS
where
RPOM_NUMBER = r.RPOM_NUMBER and
now() between DATE_ARRIVAL and DATE_DEPARTED
)

检查在给定时间段(从start_timeend_time)可用的房间:

select RPOM_NUMBER
from RESERVATIONS r
group by RPOM_NUMBER
having not exists (
select *
from RESERVATIONS
where
RPOM_NUMBER = r.RPOM_NUMBER and
{start_time} <= DATE_DEPARTED and
{end_time} >= DATE_ARRIVAL
)

关于mysql - 使用 mySQL 查找今天的免费房间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7568296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com