Instruction
Awesome! Let's learn another new operator, then. Consider the following:
SELECT *
FROM city
WHERE EXISTS (
SELECT
*
FROM trip
WHERE city_id = city.id
);
EXISTS is a new operator. It checks if there are any rows that meet the condition.
In our case, the whole query will show only information for cities where there is at least one trip (where there exists a trip) organized by our travel agency. Cities with no trips will not be shown.
Exercise
Select all countries where there is at least one mountain.
Stuck? Here's a hint!
Type:
SELECT *
FROM country
WHERE EXISTS (
SELECT
*
FROM mountain
WHERE country_id = country.id
);



