I have two tables, CITIES
and FLIGHTS
:
CITIES
id | name |
---|---|
1 | New York |
2 | Paris |
3 | Tokyo |
4 | Amsterdam |
FLIGHTS
id | departure_id | arrival_id |
---|---|---|
1 | 1 | 2 |
2 | 1 | 3 |
3 | 2 | 3 |
4 | 2 | 4 |
I need to write a query that finds all the flight connections.
The desired output would be:
departure_city | arrival_city |
---|---|
New York | Paris |
New York | Tokyo |
Paris | Tokyo |
Paris | Amsterdam |
How to write this query?