FOUND_ROWS

Returns the number of rows when using commands that return a resultset, such as SELECT, DESC, and SHOW.

Syntax

FOUND_ROWS()

Arguments

  • None.

Return Type

int

Examples

SHOW TABLES;

Results:

+--------------+
| Tables_in_db |
+--------------+
| testdata     |
+--------------+
SELECT FOUND_ROWS();

Results:

+--------------+
| FOUND_ROWS() |
+--------------+
|            1 |
+--------------+
SELECT ID FROM testdata LIMIT 2;

Results:

+------+
| id   |
+------+
|    2 |
|    4 |
+------+
SELECT FOUND_ROWS();

Results:

+--------------+
| FOUND_ROWS() |
+--------------+
|            2 |
+--------------+
SELECT * FROM testdata;

Results:

+----------+
| Results  |
+----------+
|        1 |
|        2 |
|        3 |
|        4 |
|        5 |
+----------+    
SELECT FOUND_ROWS;

Results:

+--------------+
| FOUND_ROWS() |
+--------------+
|            5 |
+--------------+
DESC testdata;

Results:

+-------+---------+------+------+---------+-----------+
| Field  | Type       | Null | Key  | Default | Extra |
+-------+-------------+------+------+---------+-------+
| id     | int(10)    | NO   |      | NULL    |       |
+--------+------------+------+------+---------+-------+
| name   | varchar(64)| NO   |      | NULL    |       |
+--------+------------+------+------+---------+-------+        
| amount | int(10)    | NO   |      | NULL    |       |
+-------+---------+------+------+---------+-----------+
SELECT FOUND_ROWS;

Results:

+--------------+
| FOUND_ROWS() |
+--------------+
|            1 |
+--------------+