title: MySQL: How to update SUM() values of children to a parent row in the same table?
body: <p>I need to get the sum values of my child rows and update that data on the parent row.
  I've got this for as shown below but ran into error #1111 (Invalid use of group function).</p>
  
  <pre><code>CREATE TEMPORARY TABLE cms_ladu_temp LIKE cms_ladu;
  
  INSERT INTO cms_ladu_temp SELECT * FROM cms_ladu WHERE parent_id IN (326,500);
  
  UPDATE 
      cms_ladu 
  INNER JOIN
      cms_ladu_temp
  ON
      cms_ladu_temp.parent_id=cms_ladu.id 
  SET  
      cms_ladu.child_packaging_units_in=SUM(cms_ladu_temp.packaging_units_in), 
      cms_ladu.child_net_weight_in=SUM(cms_ladu_temp.net_weight_in) 
  WHERE 
      cms_ladu.id IN (326,500);
  </code></pre>