This question seems to be answered multiple times. However none match the criteria I need.
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?
For example I could do this:
INSERT INTO main (SELECT * FROM temp WHERE age > 30)
DELETE FROM cache WHERE age > 30
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.
My question, is this possible, and if so. How?