我想找到餐饮服务商和快递公司开业时间之间的重叠时间 我在mysql中有这些表 表名为caterer_openings
+-----------+---------+------------+----------+
| catererID | weekDay | openedFrom | openedTo |
+-----------+---------+------------+----------+
| 1 | 1 | 08:00 | 04:00 |
| 1 | 2 | 08:00 | 23:00 |
| 1 | 3 | 08:00 | 17:00 |
| 1 | 4 | 08:00 | 17:00 |
| 1 | 5 | 09:00 | 18:00 |
| 1 | 6 | 09:00 | 18:00 |
| 1 | 7 | 09:00 | 18:00 |
+-----------+---------+------------+----------+
然后我有表caterer_openings_exceptions,其中描述了异常。
+-----------+---------------+------------+----------+
| catererID | exceptionDate | openedFrom | openedTo |
+-----------+---------------+------------+----------+
| 1 | 2016-06-20 | 08:30 | 01:30 |
+-----------+---------------+------------+----------+
表名为courier_openings,这意味着快递员将在工作日的那些时间开始提供餐饮食品
+-----------+---------+------------+----------+
| courierID | weekDay | openedFrom | openedTo |
+-----------+---------+------------+----------+
| 1 | 1 | 10:00 | 01:00 |
| 1 | 2 | 10:00 | 18:00 |
| 1 | 3 | 10:00 | 17:00 |
| 1 | 4 | 10:00 | 17:00 |
| 1 | 5 | 10:00 | 23:00 |
| 1 | 6 | 10:00 | 23:00 |
| 1 | 7 | 10:00 | 23:00 |
+-----------+---------+------------+----------+
然后我有表courier_openings_exceptions
+-----------+---------------+------------+----------+
| courierID | exceptionDate | openedFrom | openedTo |
+-----------+---------------+------------+----------+
| 1 | 2016-06-19 | 10:30 | 19:00 |
+-----------+---------------+------------+----------+
我想创建sql查询,找出最接近的可能重叠时间
我想通过MySQL和PHP获得这些结果