sqlite3 LIMIT returning duplicates when data runs out

  Kiến thức lập trình

I have a database with 1085 rows. I want to retrieve rows 1001-1085. For this I have the following query:

SELECT * FROM table WHERE email = ?1 ORDER BY sequence_number DESC LIMIT 100 OFFSET 1000;

The limit is 100 because I want to retrieve 100 rows at a time. Yes, I do need every column from the rows. The issue is instead of returning the remaining 85 rows, sqlite returns rows 1001-1085 and then appends rows 1001-1014 to the result to make it 100 returned rows. This seems weird as I would assume LIMIT to set a max returned not a necessarily returned.

I cannot seem to find anything online that explains this behavior. How can I resolve it?

LEAVE A COMMENT