Skip to main content

LeetCode 175. Combine Two Tables SQL Solution

Problem

LeetCode SQL Problem

  1. Combine Two Tables

Solution

We can join the two tables to get the address information of a person. We use left outer join to ensure each person is showing up in the result even though he/she might not have an associated address record.

SELECT p.firstName,
p.lastName,
a.city,
a.STATE
FROM Person p
LEFT JOIN Address a
ON p.personId = a.personId;