我在MySQL中存储过程,如下所示:
create procedure SP_Test (input1 varchar(20))
begin
update Table1 set Val1='Val' where country=input1;
//I want to see if this update changed how many rows and
//do some specific action based on this number
....
end
如何确定此更新更改了多少行?
答案 0 :(得分:20)
使用ROW_COUNT():
SELECT ROW_COUNT();
答案 1 :(得分:0)
一种方法,不是非常优化,只需在进行更新之前进行选择。
select count(*) from table1 where country = 'country1'
答案 2 :(得分:-1)
请尝试以下代码:
int mysql_affected_rows ([ resource $link_identifier = NULL ] )