有人可以告诉我,如果我做得好吗?我不太确定,特别是关于第二个图解释的一件事:这个绿色区域是指X和Z的值,还是X或Z?
我在代码中做了一些更正,但似乎我没有正确使用括号。不知道这段代码是否合适
-- 1
/*
// Values stored in Y, that are parts of X and Z
"Y NOT IN (Y EXCEPT (UNION OF X AND Y))"
*/
SELECT Val FROM Y
EXCEPT
SELECT Val FROM X
EXCEPT
SELECT Val FROM Z
-- 2
/*
// Values stored in Y, that are parts of X and Z
"Y NOT IN (Y EXCEPT (UNION OF X AND Y))"
*/
SELECT VAL FROM Y
INTERSECT (
SELECT Val FROM Y
EXCEPT
SELECT Val FROM X
EXCEPT
SELECT Val FROM Z
)
-- 3
/*
// Values stored in X and Z. that are not a part of Y
"(UNION OF X & Z) EXCEPT Y"
*/
SELECT VAL FROM X
UNION
SELECT VAL FROM Z
EXCEPT
SELECT VAL FROM Y
-- 4
/*
// Every value of X, and same values from Y and Z
"(Y NOT IN (Y EXCEPT (UNION OF X AND Y))) UNION X"
*/
SELECT Val FROM X
UNION(
SELECT Val FROM Y
INTERSECT
SELECT Val FROM Z)
答案 0 :(得分:0)
我同意1,3和4但是2应该是:
SELECT VAL FROM Y
EXCEPT (
SELECT Val FROM Y
EXCEPT
SELECT Val FROM X
EXCEPT
SELECT Val FROM Z
或者:
(SELECT Val FROM Y
INTERSECT
SELECT Val FROM X)
UNION
(SELECT Val FROM Y
INTERSECT
SELECT Val FROM X)