Pablo G

How Do I Count the Number of Rows that a MySQL Query Has Returned?

Asked by Pablo G 2 years ago mysql row query


Csgs
1
 
If your SQL query has a LIMIT clause and you want to know how many results total are in that data set you can use SQL_CALC_FOUND_ROWS  followed by SELECT FOUND_ROWS(); This returns the number of rows A LOT more efficiently that using COUNT(*)

Example:

Mysql> SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
    -> WHERE id > 100 LIMIT 10;
mysql> SELECT FOUND_ROWS();

by Csgs 2 years ago

Answer this question

How Do I Count the Number of Rows that a MySQL Query Has Returned?

0 errors found:

 
0