Skip to main content
Albero Academy

Filtering with WHERE

Return only the rows that match a condition.

Foundations9 min

WHERE filters rows — it keeps only those matching a condition. Together with SELECT, it answers the vast majority of data questions: "which students scored above 8?", "which orders shipped today?".

Filtering rows

WHERE conditions
SELECT name, package FROM students
WHERE package > 8;
SELECT * FROM students
WHERE programme = 'Data' AND package >= 7; -- combine with AND / OR

Useful operators

beyond =
WHERE package BETWEEN 5 AND 8 -- inclusive range
WHERE programme IN ('Data', 'Web') -- any of a list
WHERE name LIKE 'A%' -- starts with A
WHERE email IS NULL; -- missing value (not = NULL)

Key takeaways

  1. 01WHERE keeps only the rows matching a condition.
  2. 02Combine conditions with AND / OR; group with parentheses.
  3. 03Handy operators: BETWEEN (range), IN (list), LIKE (pattern).
  4. 04Use IS NULL / IS NOT NULL for missing values — never = NULL.

Finished this chapter?

Mark it complete to track your progress through SQL.