MYSQL + Select & Delete at the Same Time

时间:2022-10-28 21:46:05

Is it possible to select and delete at the same time?

是否可以同时选择和删除?

eg: in one command or does this have to be run as 2 separate commands?

例如:在一个命令中还是必须以2个单独的命令运行?

What is the most optimal way to read rows from a table (using WHERE) and then remove the rows that were read?

从表中读取行(使用WHERE)然后删除已读取的行的最佳方法是什么?

1 个解决方案

#1


3  

Yes it is possible. You could run both commands in a transaction which will commit them as one atomic unit.

对的,这是可能的。您可以在事务中运行这两个命令,将它们作为一个原子单元提交。

#1


3  

Yes it is possible. You could run both commands in a transaction which will commit them as one atomic unit.

对的,这是可能的。您可以在事务中运行这两个命令,将它们作为一个原子单元提交。