Introduction
Very simple subqueries
Subqueries with multiple results
11. The ANY operator
Correlated subqueries
Other subqueries

Instruction

Good! To sum up this section, let's learn about one more operator: ANY. Take a look:

SELECT
*
FROM Trip
WHERE Trip.Price < ANY (
SELECT
HikingTrip.Price
FROM HikingTrip
WHERE HikingTrip.MountainID = 1
);


In the above example, we want to find trips to the cities that are cheaper than any hiking trip to the mountain with ID 1 (Mont Blanc, just to let you know). There are two hiking trips to Mont Blanc: one that costs 1000 and one that costs 300. If we find a city trip that is cheaper than either of these hiking trips, we will show it in the result.

Again, other logical operator combinations are possible: = ANY, != ANY, > ANY, <= ANY, or >= ANY.

Exercise

Find all information about all city trips that have the same price as any hiking trip.

Stuck? Here's a hint!

Type:

SELECT
*
FROM Trip
WHERE Trip.Price = ANY (
SELECT
HikingTrip.Price
FROM HikingTrip
);