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 and flow from this site, held on your device and searchable with no connection. Free to install, no ads.
Get it free on the App Store