SELECT声明一个或者多个源表。如果声明了多个源表, 那么结果就是所有源表的笛卡儿积(交叉连接)。但是通常会添加一些条件(通过WHERE), 把返回行限制成笛卡儿积的一个小的子集。
inner join 相当于隐式的表达。
sql
SELECT a.city FROM airports a EXCEPT SELECT arr.city
FROM airports dep, airports arr, flights f
WHERE dep.city = 'Москва'
AND f.departure_airport = dep.airport_code
AND f.arrival_airport = arr.airport_code;
SELECT a.city FROM airports a EXCEPT SELECT arr.city
FROM airports dep, airports arr, flights f
WHERE dep.city = 'Москва'
AND f.departure_airport = dep.airport_code
AND f.arrival_airport = arr.airport_code;
sql
SELECT arr.city FROM airports dep
INNER JOIN airports arr ON f.arrival_airport = arr.airport_code
INNER JOIN flights f ON f.departure_airport = dep.airport_code
WHERE dep.city = 'Москва'
SELECT arr.city FROM airports dep
INNER JOIN airports arr ON f.arrival_airport = arr.airport_code
INNER JOIN flights f ON f.departure_airport = dep.airport_code
WHERE dep.city = 'Москва'