Skip to content

All-Access: every lesson, no ads. $8.25€8.25US$8.25$4.08US$4.08$2.41US$2.41₹224.91MX$74.91 a month, billed yearly. Free to start. Cancel any time

See plans
All-Access, no ads: every lesson, course and template. $8.25€8.25US$8.25$4.08US$4.08$2.41US$2.41₹224.91MX$74.91 a month. + GST at checkoutSee the plans →
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:

SELECT * FROM planets WHERE type = 'Gas Giant';.
Notice that in SQL, text goes inside single quotes, while numbers do not.

Table planets

planet_idnametypemoonsdistance_from_sun
101MercuryRocky058
102VenusRocky0108
103EarthRocky1150
104JupiterGas Giant79778
105SaturnGas Giant821430
106NeptuneIce Giant144500

No key for < or > on your keyboard? Use these:

Ctrl+Enter to submit

0 streak 0 XP this lessonAll Lessons

WHERE Clause - Filtering Rows - SQL Practice Online

Practise WHERE Clause - Filtering Rows with 10 interactive SQL exercises. You type real queries into your browser and get instant feedback on every answer - no database setup and no install. It is a fast, hands-on way to learn SQL online and build query skills you can use at work.