Skip to content

Commit 0abb242

Browse files
authored
Create 175_Combine_Two_Tables.sql
1 parent 629d4b3 commit 0abb242

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

175_Combine_Two_Tables.sql

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""
2+
175. Combine Two Tables
3+
Easy
4+
5+
642
6+
7+
93
8+
9+
Favorite
10+
11+
Share
12+
SQL Schema
13+
Table: Person
14+
15+
+-------------+---------+
16+
| Column Name | Type |
17+
+-------------+---------+
18+
| PersonId | int |
19+
| FirstName | varchar |
20+
| LastName | varchar |
21+
+-------------+---------+
22+
PersonId is the primary key column for this table.
23+
Table: Address
24+
25+
+-------------+---------+
26+
| Column Name | Type |
27+
+-------------+---------+
28+
| AddressId | int |
29+
| PersonId | int |
30+
| City | varchar |
31+
| State | varchar |
32+
+-------------+---------+
33+
AddressId is the primary key column for this table.
34+
35+
36+
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:
37+
38+
FirstName, LastName, City, State
39+
40+
"""
41+
# Write your MySQL query statement below
42+
43+
SELECT tb1.FirstName as FirstName, tb1.LastName as LastName, tb2.City as City, tb2.State as State
44+
FROM Person as tb1
45+
LEFT JOIN Address as tb2
46+
ON tb1.PersonId = tb2.PersonId;
47+
"""
48+
Success
49+
Details
50+
Runtime: 223 ms, faster than 42.96% of MySQL online submissions for Combine Two Tables.
51+
Memory Usage: N/A
52+
"""

0 commit comments

Comments
 (0)