175. Combine Two Tables
来源:互联网 发布:线条随鼠标特效源码 编辑:程序博客网 时间:2024/06/10 04:52
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
这里要求不论Address信息有没有都要保留Person的信息,这里是left join.
select Person.FirstName, Person.LastName, Address.City, Address.State from Personleft join Addresson Person.PersonId=Address.PersonId;
SQL 连接:
1. INNER JOIN:如果表中有至少一个匹配,则返回行;
2. LEFT JOIN:即使右表中没有匹配,也从左表返回所有的行;
3. RIGHT JOIN:即使左表中没有匹配,也从右表返回所有的行
- 来自:点击打开链接
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正则表达式详解
- concat方法
- BDD1.4更换Logo图片
- JavaScript—定义 getters 与 setters
- 如何确定特定情况下可变参数函数的参数个数
- 175. Combine Two Tables
- SQL 笔记(二)
- 信号量、互斥体和自旋锁
- 历年阿里面试题汇总(2017年不断更新中)
- 完成一个简单的时间片轮转多道程序
- Java设计模式
- scala之数据结构
- 【P-oj】-Fibonacci(矩阵)
- 高德地图API练习