为什么我从此子查询脚本中收到错误?

时间:2017-08-02 15:32:31

标签: mysql sql

我遇到了与子查询有关的问题,并从其他表中离开了。

Image

代码:

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

1 个答案:

答案 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.

不确定为什么要使用子查询