MySQL 判定两个时间段是否有重叠
原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/17183671.html
正向思维
伪代码
(oneStartTime <= otherStartTime && otherStartTime <= oneEndTime) || (oneStartTime <= otherEndTime && otherEndTime <= oneEndTime) || (oneStartTime <= otherStartTime && oneEndTime <= otherEndTime) || (otherStartTime <= oneStartTime && oneEndTime <= otherEndTime)
或
oneStartTime <= otherEndTime && oneEndTime >= otherStartTime
逆向思维
伪代码
!(otherEndTime < oneStartTime || otherStartTime > oneEndTime)
强者自救 圣者渡人