title: MySQL DELETE statement with a join, HAVING and GROUP BY
body: <p>I have a table of items and another of reports. Each report has a foreign key linking to an item being reported. </p>
  
  <p>I am trying to delete all items displayed in this query:</p>
  
  <pre><code>SELECT items.id, title, SUM(weight) AS total_weight, SUM(weight)*10/views AS score 
  FROM items, reports 
  WHERE items.id = reports.item_id 
  GROUP BY items.id 
  HAVING score &gt;= 50;
  </code></pre>
  
  <p>Trying something like this:</p>
  
  <pre><code>DELETE items 
  FROM (SELECT items.id, title, SUM(weight) AS total_weight, SUM(weight)*10/views AS score 
      FROM items, reports 
      WHERE items.id = reports.item_id 
      GROUP BY items.id 
      HAVING score &gt;= 50)
  AS T;
  </code></pre>
  
  <p>Gives me this error message:</p>
  
  <pre><code>ERROR 1109 (42S02): Unknown table 'items' in MULTI DELETE
  </code></pre>