Get the number of affected rows in a MySQL update statement?

后端 未结 3 604
有刺的猬
有刺的猬 2020-12-17 10:40

I have stored procedure in MySQL, something like the below:

create procedure SP_Test (input1 varchar(20))
begin
update Table1 set Val1=\'Val\' where country=         


        
相关标签:
3条回答
  • 2020-12-17 10:57

    Use ROW_COUNT():

    SELECT ROW_COUNT();
    
    0 讨论(0)
  • 2020-12-17 11:10

    Try the following code:

    int mysql_affected_rows ([ resource $link_identifier = NULL ] )
    
    0 讨论(0)
  • 2020-12-17 11:15

    one way, not very optimal is to simply do a select before you do the update.

    select count(*) from table1 where country = 'country1'
    
    0 讨论(0)
提交回复
热议问题