title: Error occured while writinga CTE in mysql
body: <p>I have the below query in MySQL, but when I execute it I get a syntax error message:</p>
  
  <blockquote>
    <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH CTE1 AS ( select u.FirstName,dayname(t.date) as Day, Date_Format(t.Date,"' at line 1</p>
  </blockquote>
  
  <pre><code>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 &gt;= '2018-11-01' and date &lt;= '2018-11-08'
  order by  date asc
  )
  select * from CTE1;
  </code></pre>
  
  <p>Can anyone help me on this?</p>