標籤:oracle 表串連
oracle裡表串連支援標準寫法,但也有oracle特殊的寫法,這兩種寫法在某些情境下會有差異,推薦使用標準寫法,這裡只是介紹表串連標準文法及瞭解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.columnfrom table1 ,(select table4.column,table5.column from table4,table5 where table4.column=table5.column) as table2where 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.table3where 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.columnfrom table1 ,table2where 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 ,table2where 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 ,table2where 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 ,table2where table1.column(+)=table2.column(+);
本文出自 “天黑順路” 部落格,請務必保留此出處http://mjal01.blog.51cto.com/12140495/1975625
oracle 表串連特有寫法與標準寫法