Important
The SingleStore 9.1 release candidate (RC) is available now. It will be promoted to general availability (GA) soon and at that time it will be renamed to SingleStore 10.
In the interim, SingleStore 9.1 RC can be used to preview, evaluate, and provide feedback on the new and upcoming features in SingleStore 10, while SingleStore 9.0 is recommended for production workloads.
FOUND_ ROWS
On this page
The FOUND_ function 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;
+--------------+
| Tables_in_db |
+--------------+
| testdata |
+--------------+SELECT FOUND_ROWS();
+--------------+
| FOUND_ROWS() |
+--------------+
| 1 |
+--------------+SELECT ID FROM neighborhoods LIMIT 2;
+------+
| id |
+------+
| 1 |
| 3 |
+------+SELECT FOUND_ROWS();
+--------------+
| FOUND_ROWS() |
+--------------+
| 2 |
+--------------+SELECT * FROM testdata;
+----------+
| Results |
+----------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+----------+SELECT FOUND_ROWS;
+--------------+
| FOUND_ROWS() |
+--------------+
| 5 |
+--------------+DESC testdata;
+-------+---------+------+------+---------+-----------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+------+---------+-------+
| id | int(10) | NO | | NULL | |
+--------+------------+------+------+---------+-------+
| name | varchar(64)| NO | | NULL | |
+--------+------------+------+------+---------+-------+
| amount | int(10) | NO | | NULL | |
+-------+---------+------+------+---------+-----------+SELECT FOUND_ROWS;
+--------------+
| FOUND_ROWS() |
+--------------+
| 1 |
+--------------+Note
Please note, there can be an incorrect result given when running a query using LIMIT with an offset.
CREATE TABLE t1 (a BIGINT PRIMARY KEY AUTO_INCREMENT,b INT);INSERT random integers into t1 so total row count is greater than LIMIT argument.SELECT COUNT(*)FROM t1GROUP BY aORDER BY aLIMIT 5,10;+----------+| COUNT(*) |+----------+| 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 || 1 |+----------+10 rows in set (0.03 sec)SELECT FOUND_ROWS(); -- the result should be 10+--------------+| FOUND_ROWS() |+--------------+| 15 |+--------------+1 row in set (0.00 sec)
Last modified: