Manuals / SQL / Chapter 3

A · Query · beginner · Week 1–2 · Chapter 3 of 12

WHERE, ORDER BY & LIMIT

Filter rows with WHERE. Sort with ORDER BY. Paginate with LIMIT/OFFSET. The bread and butter of exploratory queries.

Path progress
19%

Step 1 of 3

WHERE operators

=, !=, <, >, BETWEEN, IN, LIKE, IS NULL. AND/OR — use parentheses when mixing.

WHERE operatorsDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →WHERE operatorsdrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Example

SELECT id, name, email
FROM users
WHERE active = 1
  AND created_at >= '2024-01-01'
ORDER BY name ASC
LIMIT 10;

Do this now

SQLBolt lessons 2–5. Save each to sql-notes/queries/.

Was this step clear?
Chapter learning outcomes
  • WHERE conditions
  • ORDER BY
  • LIMIT/OFFSET
  • AND/OR with parentheses

Clear these before you leave

Side quest

Exploratory questions

Answer 5 business questions with SELECT + WHERE only.