SQL_CALC_FOUND_ROWS
SQL_CALC_FOUND_ROWS is a command used in MySQL to calculate the number of rows a SELECT statement would return without LIMIT clause applied. It allows MySQL to return the number of fetched rows even when you're using a LIMIT clause.
Example
Output
Explanation
In this example, SQL_CALC_FOUND_ROWS is used to calculate the total number of rows in the Customers table regardless of the LIMIT clause. The first query returns the first 5 rows from the Customers table. The second query, SELECT FOUND_ROWS(), returns the total number of rows in the table. In the provided output, the function FOUND_ROWS() returns 20, indicating there are 20 total rows in the Customers table.