Saturday, 14 September 2013

How to get total possible result set from a pagination type query?

How to get total possible result set from a pagination type query?

I'm using SQLLite in AS3 AIR, and am paginating like in the following
example query (100 results per page):
SELECT * FROM table1 WHERE col1 LIKE "%my keywords here%" LIMIT 100 OFFSET 0
It works fine - I change the offset when the user hits a next or previous
button. So the next button's subsequent query is:
SELECT * FROM table1 WHERE col1 LIKE "%my keywords here%" LIMIT 100 OFFSET
100
Just wondering if it's possible to get the total number of possible
results, so I can dsiplay 'page 3 of 12' etc? Or do I have to do two
queries - the first a count(*) without the LIMIT and OFFSET so I get the
result total, and then the above query to get the actual page result?
Thanks for your time and help.

No comments:

Post a Comment