SQLITE选择与加入一起选择仅在第二个表中的每个行中的每个行中的每个条款中都需要返回行
我需要选择要空置,即使仅第二个表中的一排不符合日期条件。,但是每个停车位在预订表中都有多个预订,即使其中一个预订符合不在范围内的标准我将获得停车位的身份证。
我的选择
SELECT Parking_Spaces.ID_Parking_Space FROM Reservations
INNER JOIN Parking_Spaces ON Reservations.ID_Parking_space = Parking_Spaces.ID_Parking_Space
AND (Reservations.Arrival_time NOT BETWEEN "2000-12-15" AND "2005-12-15")
AND (Reservations.Departure_time NOT BETWEEN "2000-12-15" AND "2005-12-15")
表示例:我不想从此表中选择ID_Parking_Space,因为第一行不符合我的状况。但是因为第二个我确实得到了ID。
|ID_RESERVATION | Arrival_time | Departure_time | ID_Parking_Space
|:------------- |:--------------:|: ------------------:|:----------------:|
| 6 | 2001-12-15 | 2002-12-15 | 4 |
| 16 | 2009-12-15 | 2010-12-15 | 4 |
在整个表中,有更多的预订,如果一行不符合条件,则我需要选择要失败。
I need the select to be empty even if only one row in the second table doesn't meet the dates condition. But each parking space has multiple reservations in Reservations table and even if one of the reservation meets the criteria of not being in the range I will get the ID of parking space.
My SELECT
SELECT Parking_Spaces.ID_Parking_Space FROM Reservations
INNER JOIN Parking_Spaces ON Reservations.ID_Parking_space = Parking_Spaces.ID_Parking_Space
AND (Reservations.Arrival_time NOT BETWEEN "2000-12-15" AND "2005-12-15")
AND (Reservations.Departure_time NOT BETWEEN "2000-12-15" AND "2005-12-15")
Table example: I don't want to SELECT ID_Parking_Space from this table, because first row doesn't meet my condition. But because second one does I do get the ID.
|ID_RESERVATION | Arrival_time | Departure_time | ID_Parking_Space
|:------------- |:--------------:|: ------------------:|:----------------:|
| 6 | 2001-12-15 | 2002-12-15 | 4 |
| 16 | 2009-12-15 | 2010-12-15 | 4 |
In the full table there are more reservations and if one row doesn't meet the condition I need the select to fail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要的是
不存在
:I think what you need is
NOT EXISTS
: