(转)Oracle数据库,join多表关联方式、union结果集合并

join on :   多表关联

内连接 :与其他表连接

from 表1 t  join 表2 s  on t.字段1 =s.字段2  join 表3 n on n.字段3=t.字段1
或
from 表1 a ,表2 b,表3c  where a.字段=b.字段

自连接: 与自身连接

from 表1 t  join 表1 s  on t.字段1 =s.字段1  s.字段1=t.字段1

 外连接:左/右连接

left join on     左连接   保证左边表的数据全部显示 

right join on    右连接  保证右边表的数据全部显示

全连接:保证两边的表的数据全部出现

full join on

union:结果集合并      

要求:前后数据的列数和字段类型要一致  

实例:

--去掉重复数据并合并 
select s.name,s.sex,t.cno from student s
union
select t.name,t.sex,t.cno from student t    

--不去掉重复数据并合并
select s.name,s.sex,t.cno from student s
union  all
select t.name,t.sex,t.cno from student t    

转自:http://www.cnblogs.com/zhaotiancheng/p/6188855.html

原文地址:https://www.cnblogs.com/jonsnow/p/6566801.html