Edward Edward - 1 month ago 4
SQL Question

What is the difference between MySQL LIMIT range of 0,500 and 1, 500?

If I want in MySQL rows 1 through 500, should I use LIMIT 0, 500 or LIMIT, 1, 500? What is the difference? Thanks!

Answer

The first one starts from the first record of the whole result, while the second one starts on the second record of the result.

Consider the following records

ID
1 -- index of the first record is zero.
2
3
4
5
6

if you execute

LIMIT 0, 3
-- the result will be ID: 1,2,3

LIMIT 1, 3
-- the result will be ID: 2,3,4

OTHER(s)