Description:write a SQL query for a report this provides the following information for each person in the person table, r Egardless If there is a address for each of the those people:
The first time to brush the SQL topic feels good. This topic is probably about connecting the first and second tables together. And the property in the address of the person in the second table may be null. This is obviously a left outer link.
# Write your MySQL query statement belowselect FirstName, LastName, city, state from person left OUTER JOIN Address on (Pe Rson. Personid=address.personid);
Here is the difference between the left and right outer links.
The left outer link is all tuples that list the left relationship, and the right outer link is all tuples that list the right relationship. Let's give an example.
PersonName (Id,name)
Data: (1, Zhang San) (2, John Doe) (3, Harry)
Personposition (id,position)
Data: (1, student) (2, teacher) (4, principal)
Results of the left connection:
Select personname.*,personposition.* from personname left join personposition on Personname.id=personposition.id;
1 31 students
2 Li 42 Teacher
3 Harry NULL NULL
Result of right outer link:
Select personname.*,personposition.* from PersonName right join personposition on personname.id=personposition.id;
1 31 students
2 Li 42 Teacher
Null NULL 4 Principal
Leetcode-combine Tables