Results 1 to 5 of 5

Thread: Left Outer Join

  1. #1
    Join Date
    Feb 2005
    Posts
    116

    Question Unanswered: Left Outer Join

    Hi Guys,

    Im a little confused with this outer join

    Im aware that lets say we have 2 tables and if i write the following

    ... from table1 left outer join table2

    My results would be generated using all rows from table1. For those rows in tables1 that dont have corresponding rows in table2, NULL are returned in the resultset for table2 column

    What if i have left outer join to more than 2 tables like below

    select table1.name,table2.school,table3.area
    from table1 left outer join table2
    on table1.id = table2.studentid left outer join table3
    on table2.schoolid = table3.areaid

    How is the data being computed here and how does it perform outer join?
    How does the query get the final results?

    Thank you very much for any explanation

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Same thing really: for table2 rows selected that have no matching table3 rows, NULLs are returned for the table3 columns. Of course, where there is no matching table2 row for a table1 row then there can't be a table3 row either.

  3. #3
    Join Date
    Feb 2005
    Posts
    116
    Quote Originally Posted by andrewst
    Same thing really: for table2 rows selected that have no matching table3 rows, NULLs are returned for the table3 columns. Of course, where there is no matching table2 row for a table1 row then there can't be a table3 row either.
    Based on your explanation, can i conclude this..
    Do you mean that it will return all records in table1 and table2
    and nulls in table2.school column that does not have corresponding records
    in table1 and nulls in table3.area column that does not have corresponding records
    in table2?

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    I think that's what I meant, though I didn't word it like that. Probably best if you create 3 tables and try it out until you understand it!

  5. #5
    Join Date
    Feb 2005
    Posts
    116
    Quote Originally Posted by andrewst
    I think that's what I meant, though I didn't word it like that. Probably best if you create 3 tables and try it out until you understand it!
    yup i will try it out, thank you

Posting Permissions

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