dongyoufo5672 2013-05-06 06:41
浏览 93

检索用户预订系统的唯一酒店ID

I have a sql related problem. I need to write a complex query for the table described below

id  date        quantity    roomtypeid  hotelid

User will search hotels using check in and check out date and specify numbers of room(quantity) with the search query, so what I need to do is get hotel ids from above table which have minimum number of rooms available from check in to check out date.

1   04-01-2013  3   4   10
2   04-02-2013  3   4   10
3   04-03-2013  3   4   10
4   04-04-2013  3   4   10
5   04-01-2013  3   4   11
6   04-02-2013  3   4   11
7   04-03-2013  3   4   11
8   04-04-2013  3   4   11
9   04-01-2013  3   4   12
10  04-02-2013  3   4   12

The resulting query should only give 10,11 as hotel id if user wants to book from 04-01-2013 to 04-03-2013 with 3 rooms.

Regards Subash

  • 写回答

2条回答 默认 最新

  • duanmeng3476 2013-05-06 07:02
    关注
    SELECT DISTINCT(`hotelid`) FROM `tableName` WHERE `date` = $checkindate AND `date` = $checkoutdate AND `quantity` = $numberofroom
    

    Use the above query. it is only dummy query modify it according you(fields name and variable names)

    评论

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行