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 ...
随机推荐
- wamp环境下composer及laravel的安装配置
laravel: PHP Web开发框架 composer: PHP 的一个依赖管理工具.它允许你申明项目所依赖的代码库,它会在你的项目中为你安装他们. 一.composer安装 参考:Windows ...
- 一些有价值bug产生的思考
1.异步处理时防止重复点击的逻辑校验 场景 打款请求时,进入异步处理的队列,生成一个任务号,存在如数据库,且状态为未完成.此时,如果并发操作,如重复点击或者重复调用接口,则发出的两条请求可能被分配到不 ...
- nginx高级用法
功能 说明 配置语法 配置位置 配置举例 结果验证 备注 rewrite 跳转重定向(不同于代理的跳转重定向,此处nginx不是代理服务器,而是本身就是web服务器) rewrite 正则表达式 re ...
- 2.Python网络编程_TCP(简略版)
TCP监听套接字: 当新的客户端请求连接时,服务器端监听套接字收到消息,会分配一个新的套接字对应于客户端(新socket包括四部分:源IP.源端口号.目的IP.目的端口号)用于接收客户端的消息,仔细观 ...
- HTTP与HTTPS初识
HTTP HTTP是一个属于应用层的协议,特点是简介.快速 HTTP客户端发起请求,创建端口HTTP服务器在端口监听客户端请求HTTP服务器向客户端返回状态和内容 网络请求,页面渲染 1.域名解析 ...
- HTML简介 页面标记
HTML简介 HTML 1.0 : 1993年 HTML 2.0 : 1995年 HTML 3.2 : 1997年 HTML 4.01 : 1999年 HTML 5 : 2008年 XML:可扩展标 ...
- logback基本使用
logback基本使用 参考 Java日志框架:logback详解 # logback官网 http://logback.qos.ch/manual/index.html 使用步骤 构建logback ...
- Mybatis拦截器(六)
拦截器的作用就是我们可以拦截某些方法的调用,在目标方法前后加上我们自己逻辑. Mybatis拦截器设计的一个初衷是为了供用户在某些时候可以实现自己的逻辑而不必去动Mybatis固有的逻辑. Mybat ...
- 小程序setData()使用和注意事项
注意: 直接修改this.data,而不调用this.setData(),是无法改变当前页面的状态的,会导致数据不一致 仅支持可以JSON化的数据 单次设置的数据不能超过1024KB,尽量避免一次设置 ...
- 震惊!CCF改名为中国沙雕化学学会!!!
震惊!中国沙雕计算机学会要改名中国沙雕化学学会??? Ak元素 据传,CCF,发现了一种新元素,元素符号暂命名为为Ak,中文名称暂未命名,据说是第250号元素. Ak 元素的发现 珂学家在一个叫洛谷的 ...
