/ Chapter 3 · Select, Filter, and Sort
Lesson 3.2 · garden_shop
Lesson 3.2

Filtering Rows with WHERE

Most of the time you don't want every row — just the ones that matter.

Most of the time you don't want every row in a table — you want the ones that matter. The WHERE clause keeps only the rows that meet a condition, and throws the rest away before they ever reach your results.

It goes right after FROM, and you can compare with =, <, >, and more. Conditions can be combined with AND and OR.

Table · customers 8 columns · 20 rows
customer_id int first_name text last_name text state text signup_date date is_active bool
Exercise · Practice

Return the first name, last name, and state of every customer from Pennsylvania (PA) who is still active.

← Back to all lessons Next · 3.3 AND, OR & parentheses