title: MySQL delete all results of sub-query
body: <p>Okay, so if you would like a back story, look at my <a href="https://stackoverflow.com/questions/1392012/showing-all-duplicates-side-by-side-in-mysql/">previous question</a></p>
  
  <p>Figuring out which of my records is not a duplicate is quite easy:</p>
  
  <pre><code>SELECT *
  FROM eventlog
  GROUP BY event_date, user
  HAVING COUNT(*) = 1
  ORDER BY event_date, user
  </code></pre>
  
  <p>This returns all of my non-duplicates. So I thought I'd move them over to another table called "no_duplicates" and then delete them from the original table. Then I could see the duplicates all alone in the original table, fix them up, and add the no_dupes back. But while:</p>
  
  <pre><code>INSERT INTO no_duplicates
  SELECT *
  FROM eventlog
  GROUP BY event_date, user
  HAVING COUNT(*) = 1
  ORDER BY event_date, user
  </code></pre>
  
  <p>Works like a charm, the following throws an error:</p>
  
  <pre><code>DELETE
  FROM eventlog
  GROUP BY event_date, user
  HAVING COUNT(*) = 1
  ORDER BY event_date, user
  </code></pre>
  
  <p>My guess is that while the query returns unique, already-in-the-table records, deleting by a aggregate function isn't kosher. Which is understandable except I don't know what else I can do to secure that only the records I moved are deleted. I searched and found no "After INSERT kill the records in the original table" syntax, and my guess is that it would fail anyway, for the same reason the delete failed.</p>
  
  <p>So, can someone help me find the missing piece?</p>