Mysql
 sql >> Datenbank >  >> RDS >> Mysql

MySQL-Abfrage - 2 Fremdschlüssel

Versehen Sie Ihre Tabellen mit einem Alias, wenn Sie die Joins durchführen:

SELECT
  flight.idflight,
  flight.idairline,
  flight.from_airport,
  flight.to_airport,
  flight.number,
  airport_from.name AS origin
  airport_to.name AS destination
FROM flight
  INNER JOIN airports airport_from ON flight.from_airport = airport_from.idairports
  INNER JOIN airports airport_to ON flight.to_airport = airport_to.idairports