开发者

Move data from one table to another

开发者 https://www.devze.com 2023-04-08 01:35 出处:网络
This question seems to be answered multiple times. However none match the criteria I 开发者_StackOverflowneed.

This question seems to be answered multiple times. However none match the criteria I 开发者_StackOverflowneed.

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?


No you can't do that.

You should use a transaction if you are worried about the integrity of your tables in between the job.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号