在Oracle中,(+)表示JOIN中的“可选”表。所以在你的查询中,
select a.id, b.id, a.col_2, b.col_2, ...
from a,b
where a.id=b.id(+)
它是一个左'外'加'表'与'一'表。就像现代的左连接查询一样。 (它会回报不失去对对方可选表“B”可以失去了数据的数据“一”表的所有数据)
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
它只会返回'a'&'b'表'id'值相同的所有数据,表示公用部分。
外:如果你想使你的查询作为权旧格式或现代再加入它会出现像波纹管:
老:
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