'Checking date coflicts in reservation schedule in mysql
I am currently developing a reservation scheduling system.
Using this query: SELECT venue_id FROM venue WHERE venue_id NOT IN (SELECT venue_id FROM reservation WHERE start_date <= '2022-05-11' AND end_date >= '2022-05-18'
I can get the available venue_id which 1 between May 11, 2022 and May 18, 2022.
|venue_id| 1
However, when I changed the start_date to '2022-05-10' and end_date to '2022-05-19' I can still get 1 as an available venue even though this venue_id is already scheduled in May 11-19:
SELECT venue_id FROM venue WHERE venue_id NOT IN (SELECT venue_id FROM reservation WHERE start_date <= '2022-05-10' AND end_date >= '2022-05-19'
result: |venue_id| 1
I want to know how to avoid this problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
