ROW_COUNT
Declaration
ROW_COUNT()
Description
Returns the number of rows affected by the executed SQL statement.
ROW_COUNT returns different values based on the type of statement:
-
DDL statements: returns
0. -
DML statements other than
SELECT: returns the number of rows affected.Specifically,
UPDATEstatements return the actual number of rows affected. -
SELECTstatements: returns-1if the execution result is a set, or the number of rows affected if theSELECTstatement changes the state of rows.For example,
SELECT .... INTOstatements return the number of rows inserted.
Examples
INSERT INTO t VALUES(1),(2),(3);
Query OK, 3 rows affected (0.02 sec)
Records: 3 Duplicates: 0 Warnings: 0
SELECT ROW_COUNT();
+-------------+
| ROW_COUNT() |
+-------------+
| 3 |
+-------------+
1 row in set (0.001 sec)