Problem Statement:-

There are many situation when we want to restrict the records that a query returns, but we want the total records that query had matched.Like, If we use LIMIT clause in the query then FOUND_ROWS() will not return the total records that query had found but the records less than or equal to the LIMIT parameter. But we can be interesting in the total records.

For example:-

There is a table customers that have 500 records and if we fire the following query

SELECT * from customers LIMIT 15



will return 15. But we want 500 as the result of FOUND_ROWS().


To solve this, there is a clause that returns the total records instead of considering LIMIT clause.

SQL_CALC_FOUND_ROWS is used to get the total records.

For above problem, we can change the query like


now if we fire


then it will return 500.

Categories: MySQL

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts


MySQL : Install MySQL on Linux Machine using yum

In the previous post we have seen how we can install java on the linux machine. This post will guide you how to install MySQL on linux machine using yum command. Install MySQL 1) To Read more…

Google Compute Engine

Access MySQL using public IP of VM instance (Google Server)

If you have MySQL on VM hosted on Google server then by default it listens on the local IP address of the machine that is on localhost ( If you want to access MySQL using public IP of VM Read more…