在Oracle中,(+)表示JOIN中的「可選」表。所以在你的查詢中,
select a.id, b.id, a.col_2, b.col_2, ...
from a,b
where a.id=b.id(+)
它是一個左'外'加'表'與'一'表。就像現代的左連接查詢一樣。 (它會回報不失去對對方可選表「B」可以失去了數據的數據「一」表的所有數據) ![enter image description here](https://i.stack.imgur.com/LSN2B.gif)
select a.id, b.id, a.col_2, b.col_2, ...
from a
Left join b ON a.id=b.id
OR
select a.id, b.id, a.col_2, b.col_2, ...
from a
Left join b using(id)
現在
如果刪除(+),那麼它會是正常的內部聯接查詢,
select a.id, b.id, a.col_2, b.col_2, ...
from a,b
where a.id=b.id
![enter image description here](https://i.stack.imgur.com/GkDx8.gif)
它只會返回'a'&'b'表'id'值相同的所有數據,表示公用部分。
外:如果你想使你的查詢作爲權舊格式或現代再加入它會出現像波紋管:
![enter image description here](https://i.stack.imgur.com/uSQlC.gif)
老:
select a.id, b.id, a.col_2, b.col_2, ...
from a,b
where a.id(+)=b.id
現代:
或
select a.id, b.id, a.col_2, b.col_2, ...
from a
Right join b using(id)
參考&幫助:
https://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:6585774577187
Left Outer Join using + sign in Oracle 11g
https://www.w3schools.com/sql/sql_join_left.asp
哦謝謝! - 根本沒有期待! – Sekhar 2010-10-26 04:56:22
沒錯。爲了保持(+)直線在我的腦海中(左側和右側),我喜歡將(+)看作「如果找不到匹配就添加NULL值」。例如,「a.id = b.id(+)」表示如果與a.id不匹配,則允許b.id爲NULL。 – beach 2010-10-26 05:00:05
謝謝..我猜想從from子句中添加它應該會得到相同的結果! – 2013-02-19 08:03:05