Oracle数据库_内连接_外连接_左连接_右连接
来源:互联网 发布:软件定制沟通 编辑:程序博客网 时间:2024/06/07 13:10
总结:
内连接:仅仅显示匹配的行
外连接:设法显示不匹配的行,包括左(外)连接、右(外)连接、全(外)连接
左(外)连接:左表的行全显示(右表不存在匹配时填null)
右(外)连接:右表的行全显示(左表不存在匹配时填null)
全(外)连接:左连接和右连接的结果再做合并(union)
SQL:
ANSI的写法 不太好看,但是意义明显。
内连接:join 或 inner join
左(外)连接:left join
右(外)连接:right join
Oracle的写法 是在需要补充填null的一方添加“(+)”,表示用null去匹配另一边“没有匹配”的行。
内连接:什么也不做
左(外)连接:右边填“(+)”
右(外)连接:左边填“(+)”
练习:
--prepare
create global temporary table temp1 (
id number(3), desc1 char(5)
);
create global temporary table temp2 (id number(3), desc2 char(5));
insert into temp1 values (123, 'ABCDE');
insert into temp1 values (456, 'FGHIJ');
insert into temp2 values (456, 'ZZZZZ');
insert into temp2 values (789, 'MMMMM');
Oracle
--left join
select a.id id_a, b.id id_b
from temp1 a, temp2 b
where a.id(+) = b.id
--right join
select a.id id_a, b.id id_b
from temp1 a, temp2 b
where a.id= b.id(+)
ASNI
--inner join(inner is optional )
select ta.id id_a, tb.id id_b
from temp1 ta
inner join temp2 tb
on ta.id = tb.id
--left join
select ta.id id_a, tb.id id_b
from temp1 ta
lest join temp2 tb
on ta.id = tb.id
--right join
select ta.id id_a, tb.id id_b
from temp1 ta
right join temp2 tb
on ta.id = tb.id
--Oracle全外连接(ASIN略)
select a.id id_a, b.id id_b
from temp1 a, temp2 b
where a.id(+) = b.id
union
select a.id id_a, b.id id_b
from temp1 a, temp2 b
where a.id = b.id(+)
- Oracle数据库_内连接_外连接_左连接_右连接
- sql语句_自连接_外连接_左连接_子查询_排序_分组
- 连接查询_内连接/外连接/交叉连接_区别(转载)
- 连接查询_内连接/外连接/交叉连接_区别
- 连接查询_内连接/外连接/交叉连接_区别
- 查询3_内连接
- 数据库_连接_JdbcOdbc桥
- SQL操作,连接查询_左连接/右连接/全连接的区别 http://www.sqlzoo.cn/
- 数据库 左外连接 右外连接 内连接
- oracle,内连接、外连接、左连接、右连接、左内连接、左外连接、右内连接、右外连接什么意思?
- 内连接,外连接,左连接,右连接,全连接
- 左连接、右连接、内连接、外连接、union连接
- 左连接、右连接、内连接、外连接、交叉连接
- Oracle 内连接,左连接 右连接 全连接
- 数据库左连接,右连接,外连接
- 内连接,外连接,左连接,右连接,全连接,内连接,交叉连接,自连接
- 内连接,外连接,左连接,右连接,全连接,内连接,交叉连接,自连接
- Oracle 的四种连接-左外连接、右外连接、内连接、全外连接
- 回调函数的概念及其使用
- ASP.NET2.0系统时,在程序中做删除或创建文件操作时,出现session丢失问题。
- 013 测试菜单2
- 异步WinInet
- GridView嵌套
- Oracle数据库_内连接_外连接_左连接_右连接
- QT主窗体在屏幕居中显示
- 线程加解锁的问题
- 留个脚印
- Understanding Linux Network Internals-4.1 The Audience for This Book
- helloaccp
- 课 程 设 计 报 告
- Autoit窗口样式扩展样式控件样式参考
- c#启动线程的时候传多个参数