How to filter with WHERE

Add a condition

WHERE is evaluated for each candidate row; only rows for which the condition is true remain.

SELECT title, level
FROM courses
WHERE level = 'beginner';

Use comparison operators

  • = equal
  • <> not equal
  • < and > less or greater
  • <= and >= inclusive comparisons

Compare compatible values

Quote text and ISO dates with single quotes; normally do not quote numbers. Double quotes are for identifiers in standard SQL.

SELECT *
FROM courses
WHERE duration_minutes >= 60;

Handle NULL separately

Comparisons with NULL are unknown, not true. Use IS NULL or IS NOT NULL.