两个时间段取交集

背景:数据库存放一个时间段,参数传过来一个时间段,看是否有交集数据

数据库:author_start、author_end         参数:startTime、endTime

思路:

1.正向思维:找两个区间的交集

y.author_start<=endTime and (y.author_end + 1)>=startTime

2.逆向思维:找出不冲突的时间取反

not(y.author_start>endTime and (y.author_end + 1)<startTime)

猜你喜欢

转载自blog.csdn.net/supershuyun/article/details/83309040