简体   繁体   English

SQL日期范围比较资源预订重复结果的冲突

[英]SQL Date Range comparison Clash for Resource Bookings Repeated Results

I am querying a booking table to see if I have a Resource Clash. 我正在查询预订表以查看是否发生资源冲突。 The query joins to the same table twice similar to this answer: 该查询两次连接到同一表,类似于此答案:

https://stackoverflow.com/a/2727467/578451 https://stackoverflow.com/a/2727467/578451

However I get duplicate results returned 但是我得到重复的结果

ie Booking 1 Clashes with Booking 2 & Booking 2 Clashes with Booking 1: 即预订1与预订2发生冲突并预订2与预订1发生冲突:

2 records returned..

booking_1_id|booking_2_id
1           |2
2           |1

Somehow I need to remove one of the (near) duplicates. 我不知何故需要删除(附近)重复项之一。 GROUP BY is not enough. GROUP BY还不够。

Ideas? 有想法吗?

SELECT * FROM (

-- your complete query here

) AS baseview
WHERE booking_1_id<booking_2_id;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM