0

我有一个要替换的查询。我不想使用“减号”运算符。

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'));

任何帮助,将不胜感激。谢谢!

4

1 回答 1

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 
)   
于 2014-06-25T02:58:17.587 回答