在两个日期之间选择

编程入门 行业动态 更新时间:2024-10-24 18:16:00
本文介绍了在两个日期之间选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨!

我有两个桌子,房间"和忙".我的繁忙表包含预订记录,其中包含到达日期和离开日期.

I have two tables, "room" and "busy". My busy table contains reservation records containing an arrival date and a departure date.

我希望选择一个在给定两个日期后都没有预订的房间.

某人给了我他要保留房间和打算离开的日期,从那以后我希望能够显示他可以使用的房间.

Someone gives me the date to which he wants to reserve his room and to which he intends to leave, from that I want to be able to show the rooms that are available to him.

忙碌表=> | IdRoom || ArrivalDate | DepartureDate |

Busy Table => |IdRoom||ArrivalDate|DepartureDate|

房间表=> | IdRoom | NumRoom |等等..|

Room Table => |IdRoom|NumRoom|And so on..|

我尝试了不同的查询,但是我什么也没得到.

I tried different queries but I don't get anything.

我经过测试的查询:

SELECT Room.*, Busy.* FROM Room INNER JOIN Busy ON Room.RoomdId= Busy.RoomdId WHERE (@dateArr NOT BETWEEN 'Busy.ArrivalDate' AND 'Busy.DepartureDate') AND (@dateDep NOT BETWEEN 'Busy.ArrivalDate' AND 'Busy.DepartureDate')

谢谢您的帮助!

推荐答案

好,所以我已更正了我的查询.

Ok so i've corrected my query.

这是我使用的查询:

SELECT * FROM Room WHERE RoomId in ( SELECT RoomID FROM Reservation WHERE EndDate <= @startDate OR StartDate >= @endDate )

当然有更好的方法可以做到,但确实可以. 谢谢大家的帮助;)

There is surely a better way to do it but it does the job. Thank you all for helping me ;)

更多推荐

在两个日期之间选择

本文发布于:2023-10-23 22:40:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1522208.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两个   日期

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!