我有一個查詢,我在MySQL中運行,它使用別名從同一列中獲取信息兩次(來自airport
表的目標)。查詢結果在使用別名時顯示兩次?
`SELECT AirlineName AS 'Airline Name',
airport1.AirportName AS 'Flying From',
airport2.AirportName AS 'Flying To',
StopType AS 'Number of Stops'
FROM flightjunction
INNER JOIN airline ON flightjunction.FlightAirline = airline.AirlineID
INNER JOIN airport AS airport1 ON flightjunction.FlightFrom = airport1.AirportID
INNER JOIN airport AS airport2 ON flightjunction.FlightTo = airport2.AirportID
INNER JOIN stops ON flightjunction.FlightStops = stops.StopID;`
但是,我注意到當我運行此查詢時出現重複的結果。我哪裏錯了?預先感謝您的幫助!
請參閱http://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple- sql-query – Strawberry