ABC DEF 2021年8月12日 2 GHI 2021年8月13日 3 JKL
我有一张桌子酒店预订
引用日期由于您没有保存结束日期,因此需要将其计算为start_date + interval numberOfDays days
以获得独占的结束日期。日期重叠查询看起来像:
SELECT *
FROM t
WHERE @d2 > start_date AND (start_date + interval numberOfDays day) > @d1
-- In order to check [2021-08-11, 2021-08-12]
-- You will set @d1 and @d2 to 2021-08-11 and 2021-08-13
为了完整起见,这里是包含结束日期的版本:
SELECT *
FROM t
WHERE @d2 >= start_date AND (start_date + interval numberOfDays - 1 day) >= @d1
-- In order to check [2021-08-11, 2021-08-12]
-- You will set @d1 and @d2 to 2021-08-11 and 2021-08-12