WHERE Clause - Filtering Rows1 / 10
In SQL, the WHERE clause lets you filter the results for rows which meet a certain criteria. Take a look at the planets table below. You want to return only the planets that are classified as Gas Giants. Try typing:
Notice that in SQL, text goes inside single quotes, while numbers do not.
SELECT * FROM planets WHERE type = 'Gas Giant';.Notice that in SQL, text goes inside single quotes, while numbers do not.
| planet_id | name | type | moons | distance_from_sun |
|---|---|---|---|---|
| 101 | Mercury | Rocky | 0 | 58 |
| 102 | Venus | Rocky | 0 | 108 |
| 103 | Earth | Rocky | 1 | 150 |
| 104 | Jupiter | Gas Giant | 79 | 778 |
| 105 | Saturn | Gas Giant | 82 | 1430 |
| 106 | Neptune | Ice Giant | 14 | 4500 |
Ctrl+Enter to submit
WHERE Clause - Filtering Rows - Free SQL Practice Online
Practise WHERE Clause - Filtering Rows with 10 free, interactive SQL exercises. You type real queries into your browser and get instant feedback on every answer - no database setup, no install, and no signup. It is a fast, hands-on way to learn SQL online and build query skills you can use at work.