当前位置:网站首页>2022.07.12_每日一题
2022.07.12_每日一题
2022-07-31 06:07:00 【诺.い】
175. 组合两个表
题目描述
表: Person
+-------------+---------+
| 列名 | 类型 |
+-------------+---------+
| PersonId | int |
| FirstName | varchar |
| LastName | varchar |
+-------------+---------+
personId 是该表的主键列。
该表包含一些人的 ID 和他们的姓和名的信息。
表: Address
+-------------+---------+
| 列名 | 类型 |
+-------------+---------+
| AddressId | int |
| PersonId | int |
| City | varchar |
| State | varchar |
+-------------+---------+
addressId 是该表的主键列。
该表的每一行都包含一个 ID = PersonId 的人的城市和州的信息。
编写一个SQL查询来报告 Person 表中每个人的姓、名、城市和州。如果 personId 的地址不在 Address 表中,则报告为空 null 。
以 任意顺序 返回结果表。
查询结果格式如下所示。
示例 1:
输入:
Person表:
+----------+----------+-----------+
| personId | lastName | firstName |
+----------+----------+-----------+
| 1 | Wang | Allen |
| 2 | Alice | Bob |
+----------+----------+-----------+
Address表:
+-----------+----------+---------------+------------+
| addressId | personId | city | state |
+-----------+----------+---------------+------------+
| 1 | 2 | New York City | New York |
| 2 | 3 | Leetcode | California |
+-----------+----------+---------------+------------+
输出:
+-----------+----------+---------------+----------+
| firstName | lastName | city | state |
+-----------+----------+---------------+----------+
| Allen | Wang | Null | Null |
| Bob | Alice | New York City | New York |
+-----------+----------+---------------+----------+
解释:
地址表中没有 personId = 1 的地址,所以它们的城市和州返回 null。
addressId = 1 包含了 personId = 2 的地址信息。
- 数据库
coding
# 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
边栏推荐
- 04-SDRAM: Read Operation (Burst)
- 从 Google 离职,前Go 语言负责人跳槽小公司
- gstreamer的caps event和new_segment event
- CHI论文阅读(1)EmoGlass: an End-to-End AI-Enabled Wearable Platform for Enhancing Self-Awareness of Emoti
- SQLite数据库连接字符串
- 【Go语言入门】一文搞懂Go语言的最新依赖管理:go mod的使用
- Automatic translation software - batch batch automatic translation software recommendation
- Difficulty comparison between high concurrency and multithreading (easy to confuse)
- 2022.07.20_每日一题
- Analysis of the implementation principle and detailed knowledge of v-model syntactic sugar and how to make the components you develop support v-model
猜你喜欢

360推送-360推送工具-360批量推送工具

Postgresql source code learning (34) - transaction log ⑩ - full page write mechanism

从 Google 离职,前Go 语言负责人跳槽小公司

批量免费文字翻译

How to use repeating-linear-gradient

芯塔电子斩获第十一届中国双创大赛芜湖赛区桂冠

Automatic translation software - batch batch automatic translation software recommendation

R——避免使用 col=0

毫米波技术基础

Difficulty comparison between high concurrency and multithreading (easy to confuse)
随机推荐
完美指南|如何使用 ODBC 进行无代理 Oracle 数据库监控?
Difficulty comparison between high concurrency and multithreading (easy to confuse)
2022.07.24_每日一题
浅层了解欧拉函数
opencv、pil和from torchvision.transforms的Resize, Compose, ToTensor, Normalize等差别
How to choose a suitable UI component library in uni-app
HighTec 的安装与配置
Foreign trade website optimization - foreign trade website optimization tutorial - foreign trade website optimization software
2. (1) Chained storage of stack, operation of chain stack (illustration, comment, code)
Postgresql source code learning (33) - transaction log ⑨ - see the overall process of log writing from the insert record
知识、创新、回报。
(border-box) The difference between box model w3c and IE
Chapter 17: go back to find the entrance to the specified traverse, "ma bu" or horse stance just look greedy, no back to search traversal, "ma bu" or horse stance just look recursive search NXM board
LeetCode brush # 376 # Medium - swing sequence
深度学习通信领域相关经典论文、数据集整理分享
科普 | “大姨太”ETH 和 “小姨太”ETC的爱恨情仇
强化学习科研知识必备(数据库、期刊、会议、牛人)
【面试:并发篇38:多线程:线程池】ThreadPoolExecutor类的基本概念
【Star项目】小帽飞机大战(七)
【Go报错】go go.mod file not found in current directory or any parent directory 错误解决