GUIDEDeep dive
SQL SELECT Basics: WHERE, ORDER, LIMIT
A SELECT reads SELECT columns, FROM table, WHERE filter, ORDER BY sort, LIMIT rows. Get the structure right first, then optimize; use LIMIT to inspect a few rows when unsure.
Clause order
SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT.
WHERE filters rows; HAVING filters groups.
Common mistakes
Quote strings with single quotes.
ORDER BY accepts a column or position.
LIMIT is not in standard SQL but is supported by SQLite, MySQL and Postgres.
FAQ
Is SELECT * good?
Fine for exploration; list columns in production.
Can WHERE use aliases?
Usually no; WHERE is evaluated before SELECT.
Sources
Related calculators
SQL Queries: 1000 Gamified SELECT Practice Cards1000 SQL query cards covering SELECT, WHERE, JOIN, GROUP BY, HAVING and subqueries, in 50 levels with spaced repetition.More guides
Hiragana vs KatakanaRead guideSpaced Repetition and the Forgetting CurveRead guideOn Readings vs Kun ReadingsRead guideAn N5 Kanji Study OrderRead guideKEEP READING
Keep reading
Read in order, or jump to another guide on the same topic.
← PreviousTimes Tables That StickFrom 2/5/10 to 7/8/9, practiced on a forgetting curve.Next →SQL JOIN and GROUP BYJoining two tables, aggregate groups and HAVING.