Reputation: 2805
I'm creating a pagination with a where clause. I need to know the true behaviour of the offset.
Edit: I want to be sure since the second behaviour would be totally incorrect and cause problems. Thanks for your answers. I can't comment as my browser fails at javascript and ajax horribly.
Upvotes: 0
Views: 314
Reputation: 191779
Are you talking about using the LIMIT
clause? LIMIT puts a cap on the number of successful matches, not the total matches. The offset portion of limit is calculated from the matches rather than all eligible rows. MySQL will not necessarily scan rows in a given order and may not scan some rows at all, so it wouldn't short change you rows if a failed match had a lower index.
Upvotes: 1
Reputation: 59670
Yes the offset is calculated based on all rows that matches the where clause. Just try it.
Upvotes: 4