Finding Overlapping Date Ranges 📅
SELECT a.*, b.* FROM reservations a JOIN reservations b ON a.start_date < b.end_date AND a.end_date > b.start_date AND a.id <> b.id;
- Check if the date ranges intersect.
- Exclude the same row from matching itself.
SELECT a.*, b.* FROM reservations a JOIN reservations b ON a.start_date < b.end_date AND a.end_date > b.start_date AND a.id <> b.id;