MySQL:返回更新的行 [英] MySQL: return updated rows
本文介绍了MySQL:返回更新的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在扭曲的python中合并这两个查询:
I am trying to combine these two queries in twisted python:
SELECT * FROM table WHERE group_id = 1013 and time > 100;
和:
UPDATE table SET time = 0 WHERE group_id = 1013 and time > 100
进入单个查询.有可能这样做吗?
into a single query. Is it possible to do so?
我尝试将SELECT放在子查询中,但我不认为整个查询都会返回我想要的内容.
I tried putting the SELECT in a sub query, but I don't think the whole query returns me what I want.
有没有办法做到这一点? (甚至更好,没有子查询) 还是我只需要坚持两个查询?
Is there a way to do this? (even better, without a sub query) Or do I just have to stick with two queries?
谢谢
Quan
推荐答案
您不能直接合并这些查询.但是您可以编写一个存储过程来执行两个查询.例如:
You can't combine these queries directly. But you can write a stored procedure that executes both queries. example:
delimiter |
create procedure upd_select(IN group INT, IN time INT)
begin
UPDATE table SET time = 0 WHERE group_id = @group and time > @time;
SELECT * FROM table WHERE group_id = @group and time > @time;
end;
|
delimiter ;
这篇关于MySQL:返回更新的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文