Knowledge Walls
John Peter
Pune, Maharashtra, India
How to get number of rows affected in mysql table
3741 Views
Hints 
Within the same transaction both requires should run. Then will return proper affected rows. This is same as php affected_rows() method works. Running in different transaction returns zero.

Run it in the stored procedure to make single transaction result by row_count() method.
Use ROW_COUNT() for Getting No of Affected Rows 
ROW_COUNT() method returns no of rows affected by insert, update or delete queries. ROW_COUNT method is same as mysql_affected_rows() method in PHP.
Output 
Example
INSERT INTO user_info VALUES("Raja"),("John"),("Siva");;
SELECT ROW_COUNT();

DELETE FROM user_info WHERE user_name IN ("Raja","John","Siva");
SELECT ROW_COUNT();
Previous Topics
Previous lessons of current book.
Best Lessons of "One day One Thing to Know"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details