mysql查询一个时间区间是否在另一个时间区间内
逻辑如下:
LimitStartTime <= StartTime <= LimitEndTime 或 LimitStartTime <= EndTime <= LimitEndTime 或 StartTime < LimitStartTime and Endtime > LimitEndTime
假设查询2022-09-07到2022-09-10的数据,Sql如下
SELECT * FROM test WHERE ( '2022-09-07' <= start_time AND start_time <= '2022-09-10' ) OR ( '2022-09-07' <= end_time AND end_time <= '2022-09-10' ) OR ( start_time < '2022-09-07' AND end_time > '2022-09-10' )
标签:09,查询,时间,2022,mysql,区间 From: https://www.cnblogs.com/supiaopiao/p/16666898.html