Filtering with WHERE
Find what matters
Lesson 3 of 20 · 6 min · Module 1: Read & shape results
You rarely need every row. The WHERE clause keeps just the records that match your condition.
Start this lesson →Free. No installation: you write and run the code in your browser, and it is checked automatically.
By the end, you’ll be able to…
- Compare a column with a value
- Filter rows with WHERE
- Quote SQL text values
The idea
Add WHERE after the table name. Compare values with =, >, or <. Wrap text values in single quotes.
SELECT * FROM learners
WHERE xp > 100;
01WHERE evaluates each row
The condition language = 'Python' is checked against every learner. Sam and Mia match. Rows that do not match are left out of the result.
02Choose the columns after defining the question
The filter can use language even when language is not one of the selected columns. The selected name and xp fields are the information you want to return.
Your turn
name and xp of learners whose language is 'Python'.What the checks look for
- Returns Sam and Mia with their XP
Take this with you
Filtering and selecting columns are separate decisions in the same query.