我这里有复杂的脚本,其中会输出log和dayname 所以我的(SELECT IF(DAYNAME(effectiveDate)=' Sunday',CONCAT(' Sunday',log) 正在工作,但在其他情况下我想输出如果用户没有时间。输出应该只是单词SUNDAY,因为条件是用户不是日志然后SUNDAY ONLY,如果用户是LOG然后LOG +星期日单词
SELECT effectiveDate,
(SELECT
(case
when note ='REGULAR LOGGED'
THEN (SELECT IF(DAYNAME(effectiveDate) ='Sunday' ,CONCAT('Sunday',log), (SELECT DAYNAME(effectiveDate) ='Sunday' FROM schedules) )
FROM schedules WHERE schedules.effectiveDate = timesheet.date AND schedules.empid = employees.empid)
end)
FROM timesheet
WHERE
schedules.effectiveDate = timesheet.date
AND counter = '1' and empid='40' AND timeStatus='OK' GROUP BY date ) am1,
DATE_FORMAT(effectiveDate, '%W') as DAY_OF_WEEK
FROM schedules
LEFT JOIN timesheet ON schedules.effectiveDate = timesheet.date
AND schedules.empid = timesheet.empid
LEFT JOIN employees ON schedules.empid = employees.empid
WHERE schedules.empid='40' and YEAR(effectiveDate) ='2017' and MONTH(effectiveDate) ='1' AND DATE_FORMAT(effectiveDate, '%W') ='Sunday'
GROUP BY effectiveDate ORDER BY effectiveDate ASC