Name

ROW_COUNT()

Synopsis

ROW_COUNT()

This function returns the number of rows changed by the previous SQL statement executed. If the previous statement was not one that could potentially change data rows—in other words, it wasn’t an INSERT, UPDATE, DELETE, or other such statement—this function will return –1. Here is an example:

SELECT ROW_COUNT();

+-------------+
| ROW_COUNT() |
+-------------+
|           4 | 
+-------------+

The results here show that four rows were changed.

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.