设为首页 加入收藏

TOP

Oracle 表连接特有写法与标准写法
2017-10-30 06:07:09 】 浏览:57
Tags:Oracle 连接 特有 写法 标准

标准连接语法:
select table1.column , table2.column
from table1
[corss join table2]
[national jon table2]
[join table2 using (column)]
[join table2 on (table1.column=table2.column)]
[left | right | full outer join table2 on (table1.column=table2.column)];


实际使用中on关键字后的连接字段不用括号也可以正常使用。


多表连接:
--先连接table4和table5并将其结果集命名为table2,再与table1连接
select table1.column,table2.column
from table1 
 inner join
( select table4.column,table5.column
  from table4 inner join table5 
  on table4.column =table5.column ) as table2 
on table1.column=table2.column;
 
等同于
select table1.column ,table2.column
from table1 ,(select table4.column,table5.column
                  from table4,table5 
                  where table4.column=table5.column) as table2
where table1.column=table2.column;
 
 
--连接table1,table2,table3,没有连接顺序之分
select table1.column,table2.column,table3.column
from table1 inner join table2 
        on  table1.column=table2.column
        inner join table3
        on table1.column=table3.column;
 
等同于
select table1.column,table2.column,table3.column
from table1,table2.table3
where table1.column=table2.column and  table1.column=table3.column;


内连接:
标准写法:
select  table.column , table2.column
from table1 inner join table2 on (table1.column=table2.column);


Oracle 特殊写法:
select table.column , table2.column
from table1 ,table2
where table1.column=table2.column;


左连接:
标准写法:
select  table.column , table2.column
from table1 left join table2 on (table1.column=table2.column);


Oracle 特殊写法:
select  table.column , table2.column
from table1 ,table2
where table1.column=table2.column(+);


右连接:
标准写法:
select table.column , table2.column
from table1 right join table2 on (table1.column=table2.column);


Oracle 特殊写法:
select  table.column , table2.column
from table1 ,table2
where table1.column(+)=table2.column;


全连接:
标准写法:
select  table.column , table2.column
from table1 full join table2 on (table1.column=table2.column);


Oracle 特殊写法:
select  table.column , table2.column
from table1 ,table2
where table1.column(+)=table2.column(+);


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇MySQL报错:ERROR 2013 (HY000): .. 下一篇Stream异常导致Oracle不断产生trc..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目