如何在MySQL中同时更新和选择 [英] How to UPDATE and SELECT at the same time in MySQL
问题描述
与此问题有关系如何同时进行UPDATE和SELECT时间 并使用以下代码:
With a relationship with this question How UPDATE and SELECT at the same time and with this code:
UPDATE table SET foo=1 WHERE boo=2
SELECT * from table WHERE foo=1 AND boo=2
如何使用MySQL同时更新和选择?
How can I UPDATE and SELECT at the same time with MySQL?
询问现有问题的人似乎使用PostgreSQL.如何在MySQL中做到这一点?看来MySQL中没有returning
命令.
It seems the person asking the existing question uses PostgreSQL. How can I do that in MySQL? It seems there is no returning
command in MySQL.
推荐答案
不幸的是,MySQL不支持RETURNING,因此您需要编写单独的语句.
Unfortunately, RETURNING is not supported by MySQL and therefore you need to write separate statements.
或者,您可以依赖存储过程.
As an alternative, you can rely on a stored procedure.
通常在这里解决MySQL是否具有等效的返回子句的问题: Mysql返回子句等价
The question of whether MySQL has a returning clause equivalent, in general, was addressed here: Mysql returning clause equivalent
这篇关于如何在MySQL中同时更新和选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!