Section 1 - Instruction

In our last session, you learned to select columns and create aliases. But what if your books table has 10,000 books and you only want fantasy novels?

Without filtering, you'd get all 10,000 rows when you only need a few dozen.

Engagement Message

On which website do you usually hit the 'Filter' button?

Section 2 - Instruction

The WHERE clause solves this by filtering rows based on conditions you specify. It acts like a gatekeeper, only letting through rows that meet your criteria.

Think of WHERE as asking "only show me rows where this condition is true."

Engagement Message

What condition might help you find only expensive books?

Section 3 - Instruction

Here's the basic WHERE structure:

This returns only books that cost exactly $19.99. The equals sign (=) checks for exact matches.

Engagement Message

What would happen if no books cost exactly $19.99?

Section 4 - Instruction

You can also use greater than (>) and less than (<) for numeric comparisons:

These find expensive books (over $20) or budget books (under $15).

Engagement Message

Which operator finds books that cost more than $10?

Section 5 - Instruction

The not equals operator (<>) finds everything except what you specify:

This returns all books except romance novels.

Engagement Message

What would this query return: WHERE price <> 0?

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal