How to determine the number of rows in the full result set and also restrict the number of rows that a query returns....


Top Questions

How to determine the number of rows in the full result set and also restrict the number of rows that a query returns,without running a second query ?

Most of the developers using 2 queries to find total number of rows and limit,when
we need pagination(1,2,3,4). why should we write 2 queries to find limit as well as total number of rows in a table.

we can achieve this in a single query.

eg:
SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
WHERE id > 567 LIMIT 10;

So SQL_CALC_FOUND_ROWS can be useful in situations when you want to restrict the number of rows that a query returns, but also determine the number of rows in the full result set without running the query again.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
13 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Check It !

Tweet It

W3 Updates

Stay informed on our latest news!

Syndicate content