Simple solution using left outer join


  • 0
    C
    select Person.FirstName, Person.LastName, Address.City, Address.State 
    from Person left outer join Address 
    on Person.PersonId = Address.PersonId;

  • 0
    H

    I use " select FirstName, LastName, City, State from Person left join Address on Person.PersonId = Address.PersonId; " accepted.

    “outer join” include" right join‘ and" left join" ?


  • 1
    K

    you can ommit outer ,just left join,the expression left outer join == left join


  • 0
    J

    @CheukyinYip but how to deal the repeated rows cuz there is the chance to have duplicate rows


  • 0
    P

    @jeffrey.zhang.7921 FULL JOIN / FULL OUTER JOIN / OUTER JOIN : returns rows when there is a match in one of the tables. ... Note that the OUTER keyword is optional for LEFT/RIGHT JOIN. LEFT and RIGHT joins are both outer joins. I believe there are some flavors of SQL that may require the OUTER keyword, but MySQL does not


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.