在MySQL中编写CTE时发生错误

时间:2018-12-03 05:20:08

标签: mysql common-table-expression

我在MySQL中有以下查询,但是在执行该查询时会收到语法错误消息:

  

您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在“ WITH CTE1 AS”附近使用(在第1行选择u.FirstName,dayname(t.date)作为Day,Date_Format(t.Date,“”

WITH CTE1 AS
(
select u.FirstName,dayname(t.date) as Day, Date_Format(t.Date,"%Y-%m-%d") As Date,  t.subtask,
IF(subtask='PTO','PTO', hours) as Emphours,

 g1.name
 from user U, task t, groupuser g, `group` g1
where  U.idUser= t.userid and g.userid= U.idUser
and g1.name='Lam-techM' and date >= '2018-11-01' and date <= '2018-11-08'
order by  date asc
)
select * from CTE1;

有人可以帮我吗?

0 个答案:

没有答案