1 / 8

PostgreSQL · SQL foundations

Ask for the columns you need

SELECT chooses columns and expressions; WHERE keeps rows whose predicate is true. Prefer an explicit select list over SELECT * in application queries: it documents what the caller uses and does not silently widen the result when a table gains columns.

SELECT id, email
FROM customers
WHERE marketing_opt_in = true;

SQL filters out rows when the predicate is false or unknown. That matters when a condition references a nullable column; the next lesson digs into that behavior.