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 ...
随机推荐
- Mysql—日志文件系统
MySQL中的日志包括:错误日志.通用查询日志.二进制日志.慢查询日志等等.这里主要介绍下比较常用的两个功能:通用查询日志和慢查询日志. 错误日志:记录启动.运行或停止mysqld时出现的问题.通用日 ...
- VS2019专业版和企业版激活密钥
Visual Studio 2019 Professional NYWVH-HT4XC-R2WYW-9Y3CM-X4V3Y Visual Studio 2019 EnterpriseBF8Y8-GN2 ...
- 解压 Android 系统中的 system.img
本篇文章讲解 system.img 是什么东西,以及它的打包和解包方式 system.img 是什么 system.img 是 Android 系统中用来存放系统文件的镜像 (image) ,文件格式 ...
- Java实现记事本|IO流/GUI
Java实现记事本 题目 利用GUI实现一个简单的记事本(notepad),即打开文件,文字内容显示在界面上: 允许对文字内容进行编辑,并可以保存到文件. 代码 package notePadExp; ...
- 精选傻X错误 && 自己的套路
声明 参考课件由Accelerator汇编 1. 随手注意的细节 你写的main 真的是 main 么? 在无向图或者网络流找反向边的时候,编号 \(xor 1\) 的前提是,你的第一条边编号是 2或 ...
- day57 choise字段与ajax
一.choice字段. 在django的orm中,创建如同性别,民.族等可选择的字段时,可以选择使用choice字段进行定义. 这样的定义可以使用简单的数字代替数据量大的字符,减少数据库的负担. ch ...
- 题解:T103342 Problem A. 最近公共祖先
题目链接 题目大意 求每个点对的lca深度的和 以每一层分析,得出通式 由于1e9的数据范围要化简表达式得到O(能过) 瞎搞后就是2^(2n+2)-(4n+2)*2^n-2 code: #includ ...
- go 通过select实现超时
package main import ( "fmt" "time" ) func main() { ch := make(chan int) quit := ...
- WordPress更改“固定链接”后 ,页面出现404的解决方法
一.Web服务器对应的是Nginx 解决方案:修改linux服务器下Nginx的配置文件,目录为:/usr/local/nginx/conf/nginx.conf, 也可以直接使用命令nginx -t ...
- QSS QPushButton:hover :pressed ...为状态下变更字体颜色(color)无效,变成字体粗细(font-weight)有效???
//字体颜色变更无效 QPushButton:hover{ font-weight:bold; color:rgba(, , , ); } //字体颜色变更有效 QPushButton#pushBut ...
