Skip to content

Commit b8a7ef5

Browse files
Add SQL solution to LC175
1 parent 4e92c8c commit b8a7ef5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

LC175-Combine-Two-Tables

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Table: Person
3+
4+
+-------------+---------+
5+
| Column Name | Type |
6+
+-------------+---------+
7+
| PersonId | int |
8+
| FirstName | varchar |
9+
| LastName | varchar |
10+
+-------------+---------+
11+
PersonId is the primary key column for this table.
12+
Table: Address
13+
14+
+-------------+---------+
15+
| Column Name | Type |
16+
+-------------+---------+
17+
| AddressId | int |
18+
| PersonId | int |
19+
| City | varchar |
20+
| State | varchar |
21+
+-------------+---------+
22+
AddressId is the primary key column for this table.
23+
24+
25+
Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those people:
26+
27+
FirstName, LastName, City, State
28+
*/
29+
30+
SELECT FirstName, LastName, City, State
31+
FROM Person
32+
LEFT JOIN Address
33+
ON Person.PersonId = Address.PersonId;

0 commit comments

Comments
 (0)