当前位置:网站首页>oracle inner join and outer join
oracle inner join and outer join
2022-08-02 03:32:00 【Tom has no Cat】
一、表的连接
1.内连接 (inner join)
What you get by doing an inner join isa和bThe columns of the association relationship exist at the same time to be connected,after inlinea和bThe associated columns are the samea中数据和bThe data are combined to form a new table data.
Inner joins will only display data that satisfies the condition
-- a 表和 b 表做内连接
-- a 表中的 bNO 和 b 表中的 NO 都不为 null 且a.bNo=b.NO form a new piece of data.
SELECT * FROM a INNER JOIN b ON(a.bNO=b.NO);
Equijoin is also an inner join
SELECT * FROM a, b WHERE a.nNO=b.NO;
2.外连接
2.1 左外连接(left outer join:简写为 left join)
Left outer join is a All rows in the table are displayed,b表 The corresponding data in are added in a The corresponding data in the table is followed by new table data.
-- a 表和 b The table is left join
-- a All columns in the table will have,b Only and in the table a The data associated with the table will follow a The table corresponds to the data behind
SELECT * FROM a LEFT JOIN b ON(a.bNO=b.NO);
在 oracle Another way of writing middle-left join:
SELECT * FROM a, b WHERE a.bNO = b.NO(+);
2.2 右外连接(right outer join :简写为 right join)
A right outer join is the opposite of a left outer join, bAll rows in the table are displayed,a 表 The corresponding data in are added in b The corresponding data in the table is followed by new table data.
-- a 表和 b Do a right join on the table
-- b All columns in the table will have,a Only and in the table b The data associated with the table will follow b The table corresponds to the data behind
SELECT * FROM a RIGHT JOIN b ON(a.bNO=b.NO);
在 oracle Another way of writing middle right join
SELECT * FROM a, b WHERE a.bNo(+) = b.NO;
2.3 全外连接(full outer join:简写为 full join)
a 表和 b The data in the table is displayed
-- a 表和 b The table is fully joined
-- a 表和 b The data in the table is displayed
SELECT * FROM a FULL JOIN b ON(a.bNO=b.NO);
3、数据集合操作
3.1 union 和 union all (并集操作)
union 和 union all 都是将多个 select The collection obtained by the query is subjected to the union operation.
使用前提:
要使用 union 或者 union all Multiple to merge select The number of queried collection fields must be the same,The corresponding field types should also be the same.
二者的区别:
union The merged results were deduplicated,union all Just merged,The merged set is not deduplicated;
union The merged collection will be sorted by default according to the order of the fields,union all 并不会进行排序;
注:
union 的效率比 union all 的效率低,所以,Use if you want to deduplicate the merged set union,Used without deduplication union all;
--union:The results obtained are only half of the first select 语句的值(进行了去重操作,And also the default sorting)
SELECT * FROM a UNION SELECT * FROM b;
--union all:The result obtained is twoselect A collection of statements merged together(No deduplication and no sorting)
SELECT * FROM a UNION ALL SELECT * FROM b;
3.2 intersect (交集操作)
intersect The operation is to combine multiple select The collection obtained by the query is subjected to the intersection operation
-- intersect:得到的是两个 select 语句的公共部分(即交集部分)
SELECT * FROM a INTERSECT SELECT * FROM b;
3.3 minus (差集操作)
minus The operation is to combine multiple select Intersection operation is performed on the obtained difference sets
-- minus:Got the previous one selectQuery out there and the latter select 没有的
SELECT * FROM a MINUS SELECT * FROM b;
边栏推荐
- 云服务器安装部署Nacos2.0.4版本
- 脚手架安装
- Scaffolding installation
- Using WebShell to get Shell Skills
- 3分钟带你了解微信小程序开发
- 活体检测 Adaptive Normalized Representation Learning for GeneralizableFace Anti-Spoofing 阅读笔记
- 周日数据库作业
- STL entry basics map and set containers
- 【程序人生】做了多年的运维,靠什么转行拿下12K+年终奖的薪资?
- AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/yolov5-5.0/models/commo
猜你喜欢

bgp机房的动态路由和静态路由的区别

CV-Model【4】:MobileNet v3

分布式领域最重要的一篇论文,到底讲了什么?

ModuleNotFoundError No module named ‘xxx‘可能的解决方案大全

通过PS 2021 将网页图标抠下来

(Repost) HashCode Summary (1)

AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘

赶紧进来!!!教你用C语言写三子棋小游戏

JVM学习----垃圾回收--G1

DAY-1 | 求两个正整数的最大公约数与最小公倍数之和——辗转相除法
随机推荐
(转帖)HashCode总结(1)
@Configuration详解
浏览器的工作原理(dns域名服务器,tcp握手,ssl/tls安全协议,关键渲染路径,重绘及回流,防抖和节流)
TRICK second bullet
云服务器安装部署Nacos2.0.4版本
JVM学习----垃圾回收--G1
np.isnan()
磷脂-聚乙二醇-叠氮,DSPE-PEG-Azide,DSPE-PEG-N3,MW:5000
「PHP基础知识」PHP中对象的使用
Chapter 10 聚类
Flexbox flex property
5.nodejs--跨域、CORS、JSONP 、Proxy
线性代数学习笔记3-1:矩阵与线性变换、常见矩阵(逆矩阵、伴随矩阵、正交矩阵等)
AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘
np.unique()函数
MySQL分组后取最大一条数据【最优解】
DAY-1 | 求两个正整数的最大公约数与最小公倍数之和——辗转相除法
mysql中如何查看表是否被锁
弹性盒子flex属性
API 低代码开发:接口大师,一套开发、管理和提供接口的产品框架