Chapter 2 of 10All chapters
Chapter 2 of 10
SELECT and WHERE
Choosing columns and filtering rows.
Picking columns
SELECT names the columns to return and FROM names the table. SELECT * returns everything, which is fine when exploring and wasteful in production code.
- AS renames a column in the output, which matters for readability.
- Expressions are allowed: SELECT price * quantity AS total.
Filtering
WHERE keeps only rows matching a condition, combined with AND, OR and NOT. IN checks a list, BETWEEN checks a range, and LIKE matches a text pattern.