我尝试将员工的工作时间存储在 mysql 表中。在表中,working_hour
我存储了正常工作时间:
id employee weekDay start end
1 1 2 10:00:00 18:00:00
2 1 3 10:00:00 18:00:00
3 1 4 10:00:00 14:00:00
4 1 5 10:00:00 12:00:00
5 1 6 10:00:00 18:00:00
6 1 7 00:00:00 00:00:00
7 1 1 00:00:00 00:00:00
在第二张表中,我存储“特殊”工作时间。我在那里存储疾病、假期或特定日期的自定义工作时间等内容。l表working_hour_specia
如下所示:
id start end type
2 12013-03-12 00:00:00 2013-03-13 23:59:59 ill
这就是我尝试过的:
SELECT
IFNULL(working_hour_special.start, working_hour.start) AS startTime,
IFNULL(working_hour_special.end, working_hour.end) AS endTime,
type
FROM
working_hour_special LEFT JOIN
working_hour ON working_hour.employee_id = working_hour_special.employee_id
WHERE
working_hour_special.start = DATE('2013-03-13') AND
employee_id = 1 AND
working_hour.weekDay = DAYOFWEEK('2013-03-13')
问题是 WHERE 子句。我需要特定员工的特定日期的开始和结束时间。有人知道怎么做吗?