我有一个想要替换的查询。我不想使用"减号"操作
SELECT t1_col1, t1_col2
FROM t1
WHERE (t1_col1, t1_col3)
IN (SELECT t2_col1, t2_col2
FROM t2
WHERE t2_col3 = '123456'
MINUS (SELECT t3_col1, t3_col2
FROM t3
WHERE t3_col4 = '123456'
UNION SELECT t3_col3, t3_col2
FROM t3 WHERE t3_col4 = '123456'));
任何帮助将不胜感激。谢谢!
答案 0 :(得分:3)
SELECT t1_col1, t1_col2
FROM t1
WHERE (t1_col1, t1_col3)
IN
(
SELECT t2_col1, t2_col2
FROM t2 , (
SELECT t3_col1 as C1, t3_col2 AS C2
FROM t3
WHERE t3_col4 = '123456'
UNION
SELECT t3_col3, t3_col2
FROM t3
WHERE t3_col4 = '123456'
) x
WHERE t2_col3 = '123456'
and t2_col1 = X.C1 (+)
and t2_col2 = x.c2 (+)
and X.C1 is null
and x.c2 is null
)