Quote:
| Originally Posted by cafelatte Your example appears to show overlapping periods. Is this intentional? |
Yes, intentional, to show that overbookings can be there as well (booking1 and booking2 are overlapping)
P.S. I have already designed the query that merges overbookings AND "2 perfectly connected bookings" (however, does NOT work for more than 2, such as: 3,4,5..n perfectly connected bookings):
----
Select distinct
(
select min(bookings2.checkin)
from bookings as bookings2
where bookings2.check_in<=bookings1.check_in
and bookings2.check_out>=bookings1.check_in
and bookings2.room_id=bookings1.room_id
) as merged_checkin
,
(
select max(bookings2.checkout)
from bookings as bookings2
where bookings2.check_out>=bookings1.check_out
and bookings2.check_in<=bookings1.check_out
and bookings2.room_id=bookings1.room_id
) as merged_checkout
,
bookings1.room_id as room_id
from bookings as bookings1
----
but then how to find the holes?