Could someone explain this is simple terms? As I don't know what offset is. Though I have a feeling it is like arrays which start from the index 0, not 1.

You can limit the number of rows affected by a statement using the LIMIT clause. When given a single numerical argument it will limit the number of rows selected, deleted, updated etc. according to the number specified.

LIMIT can accept two numerical arguments instead of one, and will use the first argument as the offset of the first row to return, and the second argument as the maximum number of rows to return. (Note: LIMIT uses 0 as the offset of the initial row instead of 1.)

SELECT * FROM pets LIMIT 3;
SELECT * FROM pets LIMIT 2, 5;
The first example will return the first 3 rows from the pets table. The second example will return 4 rows (rows 3-6, which are the 2nd, 3rd, 4th and 5th rows since the offset is 0).
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.