Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2011

    Unanswered: Can I dereference from SQL?

    This is a new guy question , I hope it is easily answered
    I would like to dereference two numbered columns to their corresponding text from a look up table in a sql statement, using a join or something like it.

    For example:

    I have a table, FlightPath:

    Flight No.______Departure__Destination

    And another table, Paths:

    Path No.___Location
    ______2____Kansas City
    ______3____Little Rock
    ______4____San Francisco

    How can I query the FlightPath table like:

    Select * from FlightPath
    where FlightNo. = 005
    replace Departure with Paths.Location where Departure = Path No.
    replace Destination with Paths.Location where Destination = Path No.

    to get :

    005___Kansas City_____Baltimore

    If i just needed to 'dereference' one column, I could use a join to the Path table and just not select my one column in the FlightPath table, but with two columns to match, I am stuck.

    Any help appreciated

  2. #2
    Join Date
    Nov 2003
    Provided Answers: 8
    SELECT fp.flight_no, 
           dep.location as departure, 
           dest.location as destination
    FROM flightpath fp
      JOIN paths dep ON fp.departure = dep.path_no
      JOIN paths dest ON fp.destination = dest.path_no
    WHERE fp.flight_no = 5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts