Reference

WHERE

Filter rows before grouping, window functions, or aggregation. WHERE runs early in logical order, so it can't reference column aliases from SELECT and can't use aggregate functions (that's what HAVING is for).

Syntax #

sql
SELECT *
FROM table_name
WHERE condition
  AND condition_2;

Example #

Loading SQL editor...
Warning

col = NULL never matches. NULL is "unknown": not equal to anything, including another NULL. Use IS NULL / IS NOT NULL instead. The same three-valued logic bites NOT IN when the subquery returns any NULL. The whole predicate becomes unknown and the outer query returns zero rows. Prefer NOT EXISTS for exclusion against a subquery.