如何在特定时间段内获得未保留的房间 [英] How Do I Get The Unreserved Rooms For A Particular Time Period
问题描述
hi.i我是sql server oracle的新手,我有一个问题:
我有2个桌子:tab房间
ID
RoomName标签预订
ID
DateStart
DateEnd
状态
评论ID_Rooms Basic我想在标签中找到房间清单的想法
房间,并在标签中预订房间
预订。 DateStart和DateEnd是
SmallDateTime类型。我的问题是使sql查询得到2
输入参数(DateStart和DateEnd),
并将返回所有未保留的房间
$ b DateStart和DateEnd之间的$ b。谢谢!
hi.i am novice with sql server oracle and I have a question:
I have 2 tables: tab Rooms
ID
RoomName tab Reservations
ID
DateStart
DateEnd
Status
Comment ID_Rooms Basic idea that I have a list of rooms in tab
Rooms, and reservations for that rooms in tab
Reservations. DateStart and DateEnd are
SmallDateTime type. My problem is to make sql query which will get 2
input parameters (DateStart and DateEnd),
and will return all rooms which are NOT reserved
in period between DateStart and DateEnd. Thanks!
推荐答案
最简单的方法是使用一个持有很长一段时间日期的临时辅助工具。例如,1-1-2000直到1-1-2050。然后,您可以轻松地从辅助表中选择所有日期,并将其与包含房间信息/预订的表格连接起来。还有一些关于这个主题的好书,比如Joe Celko的集合思维。
祝你好运!
Easiest way is using a temporal auxiliary that holds dates for a large period of time. For example, 1-1-2000 up until 1-1-2050. You can then easily select all dates from the auxiliary table and join it with the tables holding the room information/reservations. There are also some nice books on this subject like Joe Celko's thinking in sets.
Good luck!
这篇关于如何在特定时间段内获得未保留的房间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!