我知道此查询中的(+)运算符:
SELECT
*
FROM
TBL_TEST t, TBL_TEST_2 t2
WHERE
t.FIELD (+) = t2.FIELD;
但是(+)运算符在这样的查询中做了什么:
SELECT
*
FROM
TBL_TEST t
WHERE
t.FIELD (+) = 2;
我不知道......
有人可以解释一下吗?
答案 0 :(得分:2)
我有一个例子
select * from xxtest
V_ID V_NAME V_ADDRESS
5 PriceList 349FDAFD34M
7 PriceList 349FDAFD34M
7 Footer1 349FDAFD34M
5 Footer1 349FDAFD34M
5 Header1 349FDAFD34M
7 Header1 349FDAFD34M
select * from xxtest2
V_ID V_NAME V_ADDRESS
7 Header1 349FDAFD34M
查询01
select *
from xxtest aa, xxtest2 bb
where aa.v_id = bb.v_id(+) and bb.v_id(+) = 7
V_ID V_NAME V_ADDRESS V_ID V_NAME V_ADDRESS
7 PriceList 349FDAFD34M 7 Header1 349FDAFD34M
7 Footer1 349FDAFD34M 7 Header1 349FDAFD34M
7 Header1 349FDAFD34M 7 Header1 349FDAFD34M
5 PriceList 349FDAFD34M - - -
5 Footer1 349FDAFD34M - - -
5 Header1 349FDAFD34M - - -
查询02
select *
from xxtest aa, xxtest2 bb
where aa.v_id = bb.v_id(+) and bb.v_id = 7
V_ID V_NAME V_ADDRESS V_ID V_NAME V_ADDRESS
7 PriceList 349FDAFD34M 7 Header1 349FDAFD34M
7 Footer1 349FDAFD34M 7 Header1 349FDAFD34M
7 Header1 349FDAFD34M 7 Header1 349FDAFD34M
希望它能帮到你。
答案 1 :(得分:0)
强制Oracle承认它的外连接
select *
from ( select 1 n from dual
) t
where n (+) = n+1
ORA-01416:两个表不能相互外连接
:)
答案 2 :(得分:0)
我在Oracle 12G中测试了它,它返回的结果与:
相同SELECT
*
FROM
TBL_TEST t
WHERE
t.FIELD = 2;
我对原始代码的猜测是试图说明字段是否等于2,返回字段值,否则返回null。如下所示:
SELECT T.STUDENT, T2.*
FROM TBL_TEST T
LEFT OUTER JOIN (SELECT 2 COLU FROM DUAL) T2 ON T.COUNT = T2.COLU;