INTERSECT,取两个表中的交集。
举例如下:
1、创建测试表 ,
create table test_tbl_1(id varchar2(20));
create table test_tbl_2(id varchar2(20));
2 、插入测试数据,部分值含回车换行符;
insert into test_tbl_1 values(1);
insert into test_tbl_1 values(2);
insert into test_tbl_1 values(3);
insert into test_tbl_1 values(4);
insert into test_tbl_2 values(3);
insert into test_tbl_2 values(2);
insert into test_tbl_2 values(5);
insert into test_tbl_2 values(6);
commit;
3、查询表中全量数据,可以发现部分值含回车换行符;select 1 as tbl, t.*, rowid from test_tbl_1 t union all select 2 as tbl, t.*, rowid from test_tbl_2 t;
4、编写语句 ,使用INTERSECT,获取两表的交集;
select * from test_tbl_1 INTERSECT select * from test_tbl_2;
1. [intersect]∶互相交叉在一起 、交于一点 2. [be friends;make friends with]∶交朋友;做朋友
详细解释: 1. 相交往;结交。 《史记·淮南衡山列传》:“ 庐江王 边 越 ,数使使相交 ,故徙为 衡山王 ,王 江 北 。” 明 冯梦龙 《挂枝儿·缘法》:“有缘法那在容和貌?有缘法那在前后相交?” 王西彦 《病人》:“我们相交虽说不久,不过总是朋友。 ” 2. 相接 ,交战。 《秦并六国平话》卷上:“ 李牧 上阵,二马相交,惹起四野征云 ,振起满天杀气 。”《三国志平话》卷上:“ 刘备 分军三队, 关 张 二人各将一队。头至两军相交。” 3. 相好;好友 。 明 冯梦龙 《挂枝儿·是非》:“你缘何不与我争口气,相交还是我,过后悔时迟。 ”《二刻拍案惊奇》卷二十:“天下多是势利之交 ,没有黄金成不得相交。” 4. 交叉 。如:两直线相交。
数学定义
我们知道,如果两条直线只有一个公共点,就说这两条直线相交(interseetion)。该公共点就叫做这两条直线的交点(intersection point).两条直线在同一平面不平行也不重合 ,那么他们的关系就是相交 。 数学上三个圆的位置关系之一. 设两圆的半径分别为R和r,且R≥r,圆心距为d 相交为:R-r<d<R+r