Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Very simple subqueries
Subqueries with multiple results
8. The operator IN
Correlated subqueries
Other subqueries


Excellent! These examples are getting too easy for you! Let's try something more complicated.

So far, our subqueries only returned single values (like 5 or 15.28 for example). Let's change that.

First, we need to learn a new operator. Take a look at the example:

FROM city
WHERE rating IN (3, 4, 5);

Can you guess what IN means? That's right, it allows you to specify a few values in the WHERE clause instead of just one.

In our example, we only want to show interesting cities, but we're not very picky – any city with a rating 3 OR 4 OR 5 will do. That's what IN (3, 4, 5) means.


Find all information about hiking trips with difficulty 1, 2, or 3.

Stuck? Here's a hint!


FROM hiking_trip
WHERE difficulty IN (1, 2, 3);