I want to show the total number of records that matched a select query AND only records n to n+m to my user.
The way I do it now in MySQL is via two queries:
Query1: select count (*) from table 1 where <condition>;
Query2: select * from table1 where <condition> limit n, n+m;
The alternative to the above two query solution is to pull all records, without using limit keyword and then script out only the records that I want to show by looping🙁. The drawback of this method is that i am forced to pull out all the data (consumes my memory) and then I loop through the data (something that MySQL can do much better than me).
Is there a better alternative??
Thanks in advance,
Vik