I am trying to get the full found count from a query while using LIMIT to return
just a portion of the found records.  I can use two queries in a row to get
first the found count, then the found records, but that takes twice as long as
performing either query by itself.

SELECT COUNT(*) FROM database.table WHERE query
SELECT fields FROM database.table WHERE query LIMIT 10

If I use "COUNT(*),fields" in the SQL statement I have to add a GROUP BY clause. 
If I GROUP BY my auto increment field then COUNT(*) always evaluates to 1.  If I
GROUP BY a constant in every row then I get one record back with the correct
total.

Is there any way to get both the number of records found and the first set of
results using a single query?

Thanks,

[fletcher]


--
Fletcher Sandbeck                         [EMAIL PROTECTED]
Lasso Product Specialist                   [EMAIL PROTECTED]
Blue World Communications, Inc.         http://www.blueworld.com/

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to