Combine SELECT count(*) with query containing LIMIT?
Posted: Sun Feb 01, 2004 1:28 pm
Is there a way to combine the count(*) feature while using LIMIT in a SQL statement and still get the TOTAL number of records/rows that would have been retrieved if LIMIT wasn't there?
For example, if I had done SELECT * FROM table, I would have gotten 100 rows... but if I do SELECT * FROM table LIMIT 0, 20 I only get 20 rows, but I still want to know there are 100.
Essentially, like if you do a search on this site it says "400 matches found" but shows you 20 or whatever at a time. I don't want to do a SEPERATE query to get the count.
THANKS!
Peter.
For example, if I had done SELECT * FROM table, I would have gotten 100 rows... but if I do SELECT * FROM table LIMIT 0, 20 I only get 20 rows, but I still want to know there are 100.
Essentially, like if you do a search on this site it says "400 matches found" but shows you 20 or whatever at a time. I don't want to do a SEPERATE query to get the count.
THANKS!
Peter.