ORDER BY / LIMIT
SafeSorting and paging
SELECT ... ORDER BY <col> DESC LIMIT 10;
Sorts and caps results. LIMIT/OFFSET paging degrades on deep pages — switch to keyset pagination at scale.
Examples
SELECT * FROM logs ORDER BY id DESC LIMIT 20;Latest 20 rows
Syntax
ORDER BY col [DESC] LIMIT n [OFFSET m]
Before you run it
Read only.
Related commands
- SELECTRead data
- CREATE INDEXCreate an index
The same reference, with no signal at all
Every command on this site, held on your device. The app adds 632 more: 1,510 commands and 120 fix flows, searchable with no connection. Free to install, no ads (some content is a one-time purchase).
Get it free on the App Store