LeeCode——Combine Two Tables
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
解题思路较为简单,使用left join即可解决.
答案如下图所示:
# Write your MySQL query statement below
select Person.FirstName, Person.LastName, Address.City, Address.State from Person left join Address on Person.PersonId = Address.PersonId;
PS:
如果您觉得我的文章对您有帮助,请关注我的微信公众号,谢谢!
LeeCode——Combine Two Tables的更多相关文章
- LeetCode 175 Combine Two Tables mysql,left join 难度:0
https://leetcode.com/problems/combine-two-tables/ Combine Two Tables Table: Person +-------------+-- ...
- LeetCode 175. Combine Two Tables 【MySQL中连接查询on和where的区别】
一.题目 175. Combine Two Tables 二.分析 连接查询的时候要考虑where和on的区别 where : 查询时,连接的时候是必须严格满足条件的,满足了才会加入到临时表中. on ...
- LeeCode(Database)-Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- [Leetcode|SQL] Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- [LeetCode] Combine Two Tables 联合两表
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- [leetcode]Combine Two Tables
leetcode竟然有sql的题了..两道简单的应该会做 这个题主要就是一个left join... # Write your MySQL query statement below SELECT P ...
- Leetcode 175. Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- Combine Two Tables
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
- 175. Combine Two Tables【LeetCode】-LEFT JON 和RIGHT JOIN,两张表关联查询-java -sql入门
Table: Person +-------------+---------+ | Column Name | Type | +-------------+---------+ | PersonId ...
随机推荐
- TypeScript 学习笔记(一)
TypeScript: 1.是 JavaScript 的一个超集,支持 ES6 标准 2.由微软开发的自由和开源的编程语言 3.设计目标是开发大型应用,它可编译成纯 JavaScript,编译出来的 ...
- JAVA 中 Map 与实体类相互转换的简单方法
1. 在 pom.xml 中引入依赖包 <dependency> <groupId>com.alibaba</groupId> <artifactId> ...
- Docker 类面试题(常见问题)
Docker 常见问题汇总 镜像相关 1.如何批量清理临时镜像文件? 可以使用sudo docker rmi $(sudo docker images -q -f danging=true)命令 ...
- char数据类型
char数据类型就是为了中文 一个中文占两个字节正好char是占用两个字节 char a='国'’; char类型必须使用单引号属于字符类型 双引号的是字符串类型如果使用等号两边数据类型不一致就是 不 ...
- monkey参数
一.参数分类 常规类参数:包括帮助参数和日志信息参数. 帮助类参数:monkey -h -- 输出monkey命令使用指导 日志信息参数:monkey -v <event-count&g ...
- 在Python中用许多点找到两个最远点的点
我需要找到距离彼此最远的两个点. 正如屏幕截图所示,我有一个包含其他两个数组的数组.一个用于X,一个用于Y坐标.确定数据中最长线的最佳方法是什么?通过这样说,我需要选择情节中最远的两个点.希望你们能帮 ...
- 题解:T103180 しろは的军训列队
题目链接 solution: 按题目随便假设找到了一个x,它的位置的ap,属性bp 看下图 $$$$$$$$$$$$$$$$|||||P &&&&&&& ...
- xcode静态库调试
[工程1]:静态库工程,用来生成xxx.a [工程2]:项目工程,需要引入静态库xxx.a 工程2引入静态库的方法是将工程1生成的xxx.a和include头文件目录,加入到工程2中. 而如果需要在工 ...
- ubuntu串口连接linux车机设备
一.用到的命令或者程序 1.dmesg命令 2.minicom软件 二.开搞 1.安装minicom sudo apt-get install minicom 2.查看串口信息 dmesg | gre ...
- [2019BUAA软工助教]团队alpha得分总表
[2019BUAA软工助教]团队alpha得分总表 [2019BUAA软工助教]团队alpha得分总表 一.团队累计得分 累计得分图 得分总表 二.各项得分计算规则 介绍与采访 项目选择与NABCD ...
