SQL: how to join 2 columns from one tabl

wxdqz

New Member
Hi!

I have 2 tables: Fare (which lists air fares between the departure and destination using the 3-letter airport codes) and City (which maps airport codes onto the city names)

schema is as follows:

Fare table:
--------------
Fare_code (primary key)
CityCode_From (3-letter code i.e. 'LAX')
CityCode_To (3-letter code i.e. 'MCO')
Fare_Value (amount in dollars, i.e. $246)

City table:
------------
City_Code (primary key - 3 letter code,i.e. 'LAX')
City_Name (Full city name, i.e. 'Los Angeles,CA' or 'Orlando,FL'


Fare Table contains for example a record:
----------------------
'LAX','MCO',$246
------------------------

Now I want to write a SELECT query which will show me the above record like this:
---------------------------------------
Departure, Destination, Fare
------------------------------------------
'Los Angeles,CA', 'Orlando,FL', $246
------------------------------------------

HOW??????

I can do a single join of CityCode_From with City.City_Code, but how do I do it for both departure and destination codes???

I use mySQL so no UNIONS and subqueries are available

Help please!
 
Back
Top