175. Combine Two Tables
来源:互联网 发布:linux c 调用sh脚本 编辑:程序博客网 时间:2024/06/16 08:46
题目:
表 Person
PersonId
是该表的主键。
表 Address
PersonId
是该表的主键。
输出以下指定表头的信息。注意如果人物信息对应的地址为空,则输出空。
解析:
从表Person
和表Address
的结构来看,FirstName
,LastName
是属于表Person
中的属性,而City
和State
则是属于表Address
中的属性。
同时PersonId
可以作为两个表的外键,将两个表连接起来。
select Person.Firstname,Person.Lastname,Address.City,Address.Statefrom Personleft JOIN Addresson Person.PersonId=address.PersonId
要格外注意,这里要是用left join
而不是join
。因为,题目要求,不管表Person
中的人是否在Address
表中有对应的地址信息,最后都应该输出(没有的就为空)。因此,需要左连接,以Person
表为准,连接Address表
。
阅读全文
0 0
- 175. Combine Two Tables
- 175. Combine Two Tables
- 175. Combine Two Tables
- 175. Combine Two Tables
- 175. Combine Two Tables
- 175. Combine Two Tables
- 175. Combine Two Tables
- 175. Combine Two Tables
- 175. Combine Two Tables
- 175. Combine Two Tables
- LeetCode : 175. Combine Two Tables
- leetcode 175. Combine Two Tables
- leetcode.175. Combine Two Tables
- leetcode 175. Combine Two Tables
- Leetcode 175. Combine Two Tables
- leetcode 175. Combine Two Tables
- 【LeetCode】175. Combine Two Tables
- [LeetCode] 175. Combine Two Tables
- java创建SFTP通道实现文件的上传与下载
- 原生IOS-Framework封装步骤
- 关系运算符==,===和!=,!==的区别
- 简单的弹出框DEMO
- mongodb基于java开发
- 175. Combine Two Tables
- Linux下配置vim
- 恶意代码分析实战 Lab 1-4 习题笔记
- 基于spark2的推荐引擎(下)
- 结构体的定义
- redis 集群搭建
- MariaDB数据库的中主从复制的配置实现
- Docker学习笔记
- VMware Workstation虚拟机不能联网的解决办法