← Back to Lessons
🎯
Filtering with WHERE
WHERE Clause
Let's Learn! 🎓
WHERE is like using a filter on your phone! It helps you find exactly what you're looking for by setting conditions. Imagine looking for only red apples in a basket of mixed fruits.
Example Query:
SELECT name FROM users WHERE age > 18This means: 'This means: "Show me names from users table, but only for people older than 18"'
Sample Table USERS 📊
| id | age | city | name | country |
|---|---|---|---|---|
| 1 | 25 | New York | Alice | USA |
| 2 | 30 | London | Bob | UK |
| 3 | 22 | Paris | Charlie | France |
| 4 | 17 | Tokyo | Diana | Japan |
| 5 | 28 | New York | John | USA |
| 6 | 35 | London | Jane | UK |
| 7 | 19 | Paris | Jack | France |
Query Result 🖥️
| name |
|---|
| Alice |
| Bob |
| Charlie |
| John |
| Jane |
| Jack |
Understanding Each Part ⚙️
| SQL Part | Explanation |
|---|---|
SELECT name | We want to see the name column |
FROM users | Looking in the users table |
WHERE | Here comes our filter condition! |
age > 18 | Only show rows where age is greater than 18 |