How to limit results

Limit row count

SQLite, PostgreSQL, and MySQL all support LIMIT.

SELECT title
FROM courses
ORDER BY title
LIMIT 5;

Skip rows

OFFSET skips rows before returning the limit. Always pair pagination with a deterministic ORDER BY.

SELECT title
FROM courses
ORDER BY id
LIMIT 10 OFFSET 20;

Know the standard form

Standard SQL uses FETCH FIRST 5 ROWS ONLY, supported by PostgreSQL and other systems. MySQL and SQLite commonly use LIMIT.

Plan large pagination

Large offsets can be slow and can shift when rows change. Production systems often continue from the last seen key instead.