您好,这是我的数据库中的 2 个表:
我试图让酒店在一段时间内可用。在 Rooms 表中定义了房间的类型:例如 Signe:max_guests=1, Triple : max_guests=3 所以对于 10 人预订,我需要类似的东西:
SELECT SUM(rooms.max_guests * av.RoomAvailable) AS maxPeople
FROM av AS av INNER JOIN rooms
ON av.room = rooms.ID AND av.DateofDays BETWEEN '09/28/2012' AND '10/03/2012'
GROUP BY av.userid
HAVING Count(*) >= 6
但这并不真正符合我的要求..它返回给我可用的 max_people/userID 我只需要检查每个 userID(hotel) 每天是否有 >= 10 (max_people) 可用
谢谢你的帮助
更新:如果我使用这个查询:
SELECT av.userid, av.DateofDays, SUM(rooms.max_guests *
av.RoomAvailable) AS maxPeople
FROM av AS av INNER JOIN rooms
ON av.room = rooms.ID AND av.DateofDays BETWEEN '09/28/2012'
AND '10/03/2012'
GROUP BY av.userid, av.DateofDays
ORDER BY av.userid, av.DateofDays
我明白了: