ORACLE连接 (+)和Join总
来源:互联网 发布:乐高机器人的所有编程 编辑:程序博客网 时间:2024/05/01 03:42
一.笛卡尔积
a.oracle写法
scott@ORCL> select count(1) from emp;
COUNT(1)
----------
14
scott@ORCL> select count(1) from dept;
COUNT(1)
----------
4
scott@ORCL> select count(1) from emp,dept;
COUNT(1)
----------
56
b.传统sql写法
scott@ORCL> select count(1) from emp cross join dept;
COUNT(1)
----------
56
二.等值连接(也叫作内连接)
a.oracle写法
scott@ORCL> select count(1) from emp a,dept b where a.deptno=b.deptno;
COUNT(1)
----------
14
b.传统sql写法
scott@ORCL> select * from emp a join dept b on a.deptno=b.deptno;
else1:等值连接的记录筛选
a.
scott@ORCL> select * from emp a,dept b where a.deptno=b.deptno and a.deptno=30;
b.
scott@ORCL> select * from emp a join dept b on a.deptno=b.deptno where a.deptno=30;
else2:不等值连接
a.
scott@ORCL> select * from emp a,salgrade b where a.sal>=b.losal and a.sal<=b.hisal;
b.
scott@ORCL> select * from emp a join salgrade b on a.sal between b.losal and b.hisal;
三.外连接
1.左外连接(left outer join)
a.
scott@ORCL> select * from emp a,dept b where a.deptno=b.deptno(+);
b.
scott@ORCL> select * from emp a left outer join dept b on a.deptno=b.deptno;
2.右外连接
a.
scott@ORCL> select * from emp a,dept b where a.deptno(+)=b.deptno;
b.
scott@ORCL> select * from emp a right outer join dept b on a.deptno=b.deptno;
3.全外连接
a.
scott@ORCL> select * from emp a,dept b where a.deptno(+)=b.deptno union
2 select * from emp a,dept b where a.deptno=b.deptno(+);
b.
scott@ORCL> select * from emp a full outer join dept b on a.deptno=b.deptno;
四.自然连接:根据两个表的相同字段
scott@ORCL> select * from emp natural join dept b;
如果两张表没有相同字段会报错:没有选定行
五.using字句:指定表的某个字段作为连接的字段
scott@ORCL> select * from emp a join dept b using(deptno);
- ORACLE连接 (+)和Join总
- oracle join on 连接
- oracle join连接方法以及left join中on 和where的区别
- oracle 内外连接 join 总结
- Oracle natural join(自然连接)
- Oracle natural join(自然连接)
- Oracle数据库之外连接和分组查询:left,right,full join 和表连接
- LEFT JOIN 和JOIN 多表连接
- ★★★ oracle外连接,Oracle中Left Outer Join和外关联(+)的区别
- oracle 内连接(inner join)、外连接(outer join)、全连接(full join)
- oracle 中 inner join内连接、 left join左连接、right join右连接用法
- oracle 内连接(inner join)、外连接(outer join)、全连接(full join)
- oracle 内连接(inner join)、外连接(outer join)、全连接(full join)
- 深入理解Oracle表(3):三大表连接方式详解之Nested loop join和 Sort merge join
- ORACLE的left join、right join和inner join详解
- Oracle中的left join,right join和inner join
- oracle的表连接hash join、nested loop join
- oracle inner join 隐藏的多次连接
- JavaScript String对象 操作
- Photoshop CS6 破解
- 最长上升子序列的两种方法
- 传感器应用集合
- 再记看牡丹
- ORACLE连接 (+)和Join总
- NYIST 811变态最大值
- 高并发带来的重复提交问题解决方案
- 第5周 经典小程序2题 C语言实现的猜拳游戏(剪子锤子布)
- kafka Java实例
- PHP中的$this用法
- 从零开始变大牛
- hibernate shards分库的实现
- hdu 5665 Lucky(简单题)(bestcoder#80 1000)