Just add SQL_CALC_FOUND_ROWS to your select statement:
SELECT SQL_CALC_FOUND_ROWS COUNT(*)...;
The you can execute a "special" query to figure out how many rows
would have been returned without the LIMIT clause.
SELECT FOUND_ROWS();
On Sep 7, 2005, at 6:15 AM, pow wrote:
Hi everyone, Im executing the following query:
SELECT *
FROM
table1
WHERE
table1.field1 = 'A' AND table1.field2 = 'B'
LIMIT 0,10
I also need to get the total record count for the above query, but
without the limit clause (limit is for pagination purposes)
Is there any way to extract this total record count without the
need to do another query?
Right now I am using another query to get the total record count:
SELECT COUNT(*)
FROM
table1
WHERE
table1.field1 = 'A' AND table1.field2 = 'B'
In reality, my tables are very large, and involve joins, so
executing the query TWICE is taking its toll on the server.
Thanks!
Pow
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?
[EMAIL PROTECTED]
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]