SQL Cheat Sheet/Paginate with LIMIT and OFFSET

Skip rows and return a page-sized result set.

Section: Sorting and Limiting

Paginate with LIMIT and OFFSET

sql
sql
SELECT *
FROM posts
ORDER BY published_at DESC
LIMIT 20 OFFSET 40;
Explanation

Offset pagination is simple but can be slower for large offsets.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Sorting and Limiting
Limit returned rows
Return only the first N rows.
OpenIn sheetsqlsame section
Fetch first rows
Use standard SQL row limiting syntax.
OpenIn sheetsqlsame section
Sort rows
Order query results ascending or descending.
OpenIn sheetsqlsame section
Select all columns
Return all columns from a table.
Filter with equality
Return rows matching an exact value.
Inner join two tables
Return rows with matches in both tables.