WHERE

Keep only the rows that match a condition. It runs before grouping.

Syntax

SELECT … FROM table_name WHERE condition;
  • Combine conditions with AND, OR and NOT. Use parentheses when you mix AND and OR.

Example

SELECT order_id, order_date FROM orders WHERE channel = 'online' AND order_date >= '2025-09-10';

Online orders placed from 10 September onwards.

Tables used: orders. Try it in a lesson below.

Common mistakes

  • Compare missing values with IS NULL, never with = NULL.
  • Text values go in single quotes. Double quotes name columns.

Practise it