Syntax
ROW_COUNT()
Purpose
ROW_COUNT() returns the number of rows that are affected by the executed SQL statement.
ROW_COUNT returns different values based on the statements:
DDL statements:
0is returned.DML statements other than
SELECT: The number of affected rows is returned.Note that if an
UPDATEstatement is executed, the number of actually updated rows is returned.SELECTstatement: If the execution result of theSELECTstatement is a set,-1is returned. If the execution of theSELECTstatement affects the row status, the number of affected rows is returned.For example, if the
SELECT .... INTOstatement is executed, the number of inserted rows is returned.
Examples
obclient> INSERT INTO t VALUES(1),(2),(3);
Query OK, 3 rows affected (0.02 sec)
Records: 3 Duplicates: 0 Warnings: 0
obclient> SELECT ROW_COUNT();
+-------------+
| ROW_COUNT() |
+-------------+
| 3 |
+-------------+
1 row in set