Forums Register Login

Pagination - Skipping rows in rs

+Pie Number of slices to send: Send
I'm going to try this method of pagination retrieve from the FAQs. I have never had the necessity of using anything less than the entire ResultSet. How do I skip rows? Is it done with the ResultSet object? If not, I can do this in a loop by counting to the row I want to begin on. I just thought there might be a way to jump to the row I want. Is there?

Repeat the query for each new request.
Algorithm
Client requests page 1
Execute the query
Return rows for page 1
Client requests page 2
Execute the query
Skip rows for page 1
Return rows for page 2
+Pie Number of slices to send: Send
I think I found it. Is it the absolute() method?
+Pie Number of slices to send: Send
Lisa,
Absolute is pretty much equivalent to rs.next(). The driver still pulls in all the rows over the network.

For pagination, people typically limit the results in the SQL query. The syntax varies based on your database. What database are you using?
+Pie Number of slices to send: Send
Well, I'm using SQLServer. I thought I looked into limiting the results and that SQLServer does not have the same functions as MySQL. I thought, based on some posts, that you can only retrieve from the top in SQLServer and not from within the middle. Please let me know how if it is possible to retrieve, for example, rows 11 - 20.

Thanks!
+Pie Number of slices to send: Send
 

Originally posted by Lisa Modglin:
Well, I'm using SQLServer. I thought I looked into limiting the results and that SQLServer does not have the same functions as MySQL. I thought, based on some posts, that you can only retrieve from the top in SQLServer and not from within the middle. Please let me know how if it is possible to retrieve, for example, rows 11 - 20.

Thanks!



To make the example clearer, let's say you want rows 31-40 (page 4, 10 rows per page) from:
SELECT x FROM table ORDER BY Y

You can do it something like this (I don't have a DB to test it on):



In other words, you select the top 40, invert the order and select the top 10, and reorder for the final result.
Oh the stink of it! Smell my tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1262 times.
Similar Threads
Pagination
How to do the pagination?
Pagination
Pagination
pagination
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:48:43.