title: How to update a table using a select group by in a second one and itself as the data source in MySQL?
body: <p>I can do this:</p>
  
  <pre><code>SELECT t2.value + sum(t3.value)
  FROM tableA t2, tableB t3
  WHERE t2.somekey = t3.somekey
  GROUP BY t3.somekey
  </code></pre>
  
  <p>But how to do this?</p>
  
  <pre><code> UPDATE tableA t1
      SET speed = (
          SELECT t2.value + sum(t3.value)
          FROM tableA t2, tableB t3
          WHERE t2.somekey = t3.somekey
          AND t1.somekey = t3.somekey
          GROUP BY t3.somekey
     )
  ;
  </code></pre>
  
  <p>MySQL says it's illegal since you can't specify target table <code>t1</code> for update in FROM clause.</p>