Results 1 to 7 of 7

Thread: SQL Statement

  1. #1
    Join Date
    Jan 2012
    Posts
    12

    Red face Unanswered: SQL Statement

    Hi All,

    I have two tables look like following,

    TABLE 01 has three columns flightNO,dest_airport_code,Origin_airport_code
    TABLE 02 has two columns airport_code,airport_name

    I want to retrive flightNO,dest_airport_code,airport_name,Origin_air port_code,airport_name

    airport_name after the dest_airport_code is the relavent airport name and airport_name after the origin_airport_code means the relavent origin airport name.How can I retrive these columns.

    please help me.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    use WHERE clause to join the three tables
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jan 2012
    Posts
    12

    SQL statement

    I used it as follows


    select flightNo,origin_airport_code,airport_name "origin" ,dest_airport_code,airport_name "dest"
    from table_01 a,table_02 b
    where b.airport_code=a.origin_airport_code and b.airport_code=a.dest_airport_code;


    but it doesnt retrive any row.

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    your SQL only returns rows when a.origin_airport_code=a.dest_airport_code;

    select flightNo,origin_airport_code,airport_name "origin" ,dest_airport_code,airport_name "dest"
    from table_01 a,table_02 b1, table_02 b2
    where <you fill in missing details>
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Jan 2012
    Posts
    12
    thank you so much!!! it works !!.

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    That is why I said THREE tables in previous response
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  7. #7
    Join Date
    Jan 2012
    Posts
    12
    yes.now I can understand it.first I was confused where is the THREE tables.now it is ok Thank you again.

Posting Permissions

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