title: How Can i write update statement in mysql with select query?
body: <p>I want to update table1 by taking <code>max(date) and min(Date) from Table2</code> for only if <code>table1.status=100</code> and <code>table1.Todate='0000-00-00 00:00:00'</code>
  same thing I am trying with following query but it is giving error in group by</p>
  
  <pre><code>update table1 s 
  left join table2  t 
  on s.stCode=t.tsTask 
  set s.stActFrom= min(t.tsDate),s.stActTo=max(t.tsDate)
  WHERE s.stActTo='0000-00-00 00:00:00' and s.stStatus=100 
  group by t.`tsTask`
  </code></pre>
  
  <p>if i execute this query i am getting following error.
  <code>#1064 - 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 'group by t.</code>tsTask<code>' at line 1</code></p>
  
  <p>Can any one tell me how i can write this update query?</p>