1 Star 0 Fork 332

大哥 / leetcode

forked from doocs / leetcode 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README_EN.md 1.23 KB
一键复制 编辑 原始数据 按行查看 历史
ylb 提交于 2021-04-22 11:34 . feat: use relative path

175. Combine Two Tables

中文文档

Description

Table: Person


+-------------+---------+

| Column Name | Type    |

+-------------+---------+

| PersonId    | int     |

| FirstName   | varchar |

| LastName    | varchar |

+-------------+---------+

PersonId is the primary key column for this table.

Table: Address


+-------------+---------+

| Column Name | Type    |

+-------------+---------+

| AddressId   | int     |

| PersonId    | int     |

| City        | varchar |

| State       | varchar |

+-------------+---------+

AddressId is the primary key column for this table.

 

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:


FirstName, LastName, City, State

Solutions

SQL

# Write your MySQL query statement below
SELECT p.FirstName, p.LastName, a.City, a.State
FROM Person p
LEFT JOIN Address a
ON p.PersonId = a.PersonId;
Java
1
https://gitee.com/dagechen/leetcode.git
git@gitee.com:dagechen/leetcode.git
dagechen
leetcode
leetcode
main

搜索帮助