gpt4 book ai didi

mysql - 按抵达日期和离开日期之间的价格获取可用客房

转载 作者:行者123 更新时间:2023-11-29 18:27:03 24 4
gpt4 key购买 nike

价格计划主表

CREATE TABLE `price_plan_master` (
`id` int(11) NOT NULL COMMENT 'Id ( Auto Increment )',
`room_id` int(11) NOT NULL COMMENT 'Room Id (Related to room_master table)',
`date` date NOT NULL COMMENT 'Date to get rate',
`no_of_rooms` int(11) NOT NULL COMMENT 'No of rooms available',
`rate` double NOT NULL COMMENT 'Room rate',
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Id|room_id|date|no_of_rooms|rate
1|2|2017-10-01|5|8530
2|2|2017-10-02|5|8530
3|3|2017-10-01|5|8200
4|3|2017-10-02|5|8200
5|2|2017-10-01|2|14609
6|2|2017-10-02|2|14609
7|3|2017-10-03|2|14609
8|2|2017-10-04|2|14609
9|3|2017-10-01|2|13000
10|3|2017-10-02|2|13000
11|3|2017-10-03|2|13000
12|3|2017-10-04|2|13000
13|6|2017-10-01|3|17286
14|6|2017-10-02|3|17286
15|6|2017-10-03|3|17286
16|6|2017-10-04|3|17286
17|11|2017-10-01|10|2830
18|11|2017-10-02|10|2830
19|11|2017-10-03|10|2830
20|11|2017-10-04|10|2830
21|12|2017-10-01|2|1700

我想获取所有有条件的房间在请求的入住日期和退房日期之间,可用性应等于或最大请求的房间数(意味着 no_of_rooms >= 3)。对于日期范围内的每个日期,都应检查客房供应情况。

目前,我正在使用以下查询。

select * from price_plan_master
where date >= checkin and date <= checkout

我需要检查所有日期的可用性。

任何人都可以建议我应该在单个查询中更改什么来获取记录吗?

最佳答案

您可以使用您编写的带有添加的 AND 条件的查询:

 select * from price_plan_master
where date >= checkin and date <= checkout
and no_of_rooms >= 3

这将选择日期范围内房间数量大于或等于请求的房间数量的所有房间。

关于mysql - 按抵达日期和离开日期之间的价格获取可用客房,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46096359/

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