我遇到了与子查询有关的问题,并从其他表中离开了。
代码:
SELECT effectiveDate,
(SELECT
CASE
WHEN note='REGULAR LOGGED' THEN log
END
FROM schedules LEFT JOIN timesheet ON schedules.effectiveDate = timesheet.date WHERE schedules.empid='40'
AND YEAR(effectiveDate) = YEAR(CURDATE()) AND MONTH(effectiveDate) ='1' GROUP BY effectiveDate
)
FROM schedules
LEFT JOIN timesheet ON schedules.effectiveDate = timesheet.date WHERE schedules.empid='40'
AND YEAR(effectiveDate) = YEAR(CURDATE()) AND MONTH(effectiveDate) ='1' GROUP BY effectiveDate
答案 0 :(得分:0)
这是您的实际查询
SELECT effectiveDate,
CASE
WHEN note='REGULAR LOGGED' THEN log
END
FROM schedules LEFT JOIN timesheet ON schedules.effectiveDate = timesheet.date WHERE schedules.empid='40'
AND YEAR(effectiveDate) = YEAR(CURDATE()) AND MONTH(effectiveDate) ='1' GROUP BY effectiveDate.
不确定为什么要使用子查询