-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCombine_Two_Tables176.sql
More file actions
26 lines (21 loc) · 934 Bytes
/
Combine_Two_Tables176.sql
File metadata and controls
26 lines (21 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- Person schema
-- +-------------+---------+
-- | Column Name | Type |
-- +-------------+---------+
-- | personId | int |
-- | lastName | varchar |
-- | firstName | varchar |
-- +-------------+---------+
-- Address schema
-- +-------------+---------+
-- | Column Name | Type |
-- +-------------+---------+
-- | addressId | int |
-- | personId | int |
-- | city | varchar |
-- | state | varchar |
-- +-------------+---------+
-- Write an SQL query to report the first name, last name, city, and state of each person in the Person table. If the address of a personId is not present in the Address table, report null instead.
-- personId is the primary key column for this table.
-- This table contains information about the ID of some persons and their first and last names.
select p.firstName,p.lastName,a.city,a.state from Person p left outer join Address a on p.personId=a.personId;