SELECT and Columns
- SELECT basics. A SELECT names the columns you want FROM a table: the smallest complete question you can ask.
- Aliases. The AS keyword renames a column or table for one query: price_cents AS price reads better downstream.
- Star discipline. SELECT star grabs every column: fine while exploring, a liability in production code that outlives the schema.
Filtering and Sorting
- WHERE. The WHERE clause keeps only rows whose condition is true: filtering happens before anything else you see.
- ORDER BY. ORDER BY sorts the result: without it, row order is an accident the engine may change tomorrow.
- LIMIT. LIMIT caps the rows returned: with ORDER BY it answers every top-ten question.
Basic Query Construction
- Logical order. Queries evaluate in a fixed logical order: FROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY: read them that way.
- Combining conditions. AND, OR and parentheses combine filters: parentheses make mixed conditions honest instead of surprising.
- DISTINCT. DISTINCT collapses duplicate result rows: and is often a sign a join fanned out more than intended.
Before and after this level
- Before: Start Here: Think in Tables and Sets: Relational Data, Queries vs Application Code.
- Next: Level 2: Expressions & Data: Data Types, Operators and Functions, NULL and Three-Valued Logic.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does SQL Level 1: Query Foundations cover?
SELECT and Columns, Filtering and Sorting, Basic Query Construction: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Start Here: Think in Tables and Sets, which covers Relational Data, Queries vs Application Code.