2
我有这两个表MySQL查询 - 2个外键
airports: airportid, airportname
flights: flightid, from_airport, to_airport
其中from_airport
和to_airport
是外键。
我可以连接的表或者在airportid
和from_airport
或airportid
和to_airport
,要么我得到的to_airport
或from_airport
名字名字,但我想无论是在一个查询或以最低的成本来选择这两个to_airport
和from_airport
名。
有没有可能?怎么样??
这里是我的查询:做的时候
SELECT
flight.idflight,
flight.idairline,
flight.from_airport,
flight.to_airport,
flight.number,
airports.name AS origin
FROM
flight
Inner Join airports ON flight.from_airport = airports.idairports