title: Move data from one table to another
body: <p>This question seems to be answered multiple times. However none match the criteria I need. </p>
  
  <p>Is it possible to select (and insert them in another table) and delete rows from the original table in Mysql without running the selected criteria twice?</p>
  
  <p>For example I could do this:</p>
  
  <pre><code>INSERT INTO main (SELECT * FROM temp WHERE age &gt; 30)
  DELETE FROM cache WHERE age &gt; 30
  </code></pre>
  
  <p>However with a very complex and long running query the 'match part' of the query would be executed twice, whilst I think that there should be a solution to delete the selected items, since you have fetched them already anyways.</p>
  
  <p>My question, is this possible, and if so. How?</p>