MySQL Forums
Forum List  »  Newbie

MySQL pagination
Posted by: Eran Yasso
Date: September 01, 2017 12:29AM


I have a web server which sends to mobile app list of products. The products are stored in MySQL server. PK for the table is productPoC_id . I am sending the products to mobile app in paging.

Page size is 500 records. I am using following select statement:
"SELECT * FROM productPoC WHERE productPoC_id > @productId ORDER by productPoC_id ASC LIMIT @limit OFFSET @offset".
In first call I set productId to 0, limit to 500 and offset 0. MySQL returns me correctly the records (productPoC_id is from 1 to 500). The problem is in second call. In second call I set productId to 500, and offset to 500. In this case MySQL returns me productPoC_id 1000 instead of 501 (note that I serialized all the productPoC_id from 1 to 150000). I would expect MySQL to return productPoC_id 501. When I remove the offset from the select, productPoC_id correctly (starting from 501).

I am trying to understand why in the first sample I am not getting the right productPoC_id.


Options: ReplyQuote

Written By
MySQL pagination
September 01, 2017 12:29AM
September 01, 2017 09:57AM
September 02, 2017 11:14AM
September 02, 2017 12:16PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.