R
Rick
I need to execute an SQL stament with a non-bitwise XOR (Exclusive_OR)
relation.
For example, suppose I have the following tables:
a = {1, 2, 3, 4, 5, 7, 8}
b = {3, 5, 8, 10, 11, 12}
a AND B in SQL = {3. 5. 8}
a OR B in SQL = {1, 2, 3, 4, 5, 7, 8, 10, 11, 12}
now, A XOR B = {1, 2, 4, 7, 10, 11, 12}
in othe words, the output should give:
ALL but not the ones that are common (All except a AND B).
In SQL 2005; I can do it, but probably in access is totally different:
CREATE TABLE a ( col int )
GO
INSERT INTO a VALUES (1)
INSERT INTO a VALUES (2)
INSERT INTO a VALUES (3)
INSERT INTO a VALUES (4)
INSERT INTO a VALUES (5)
INSERT INTO a VALUES (7)
INSERT INTO a VALUES (8)
GO
CREATE TABLE b ( col int )
GO
INSERT INTO b VALUES (3)
INSERT INTO b VALUES (5)
INSERT INTO b VALUES (8)
INSERT INTO b VALUES (10)
INSERT INTO b VALUES (11)
INSERT INTO b VALUES (12)
-- a AND B in SQL = {3. 5. 8}
SELECT col
FROM a
INTERSECT
SELECT col
FROM b
-- a OR B in SQL = {1, 2, 3, 4, 5, 7, 8, 10, 11, 12}
SELECT col
FROM a
UNION
SELECT col
FROM b
(SELECT col FROM a UNION SELECT col FROM b)
EXCEPT
(SELECT col FROM a INTERSECT SELECT col FROM b)
pleeeze, only a hint.
--
Thanks,
Rick.
"For every problem, there is a solution that is simple, neat, and wrong."
H. L. Mencken"
relation.
For example, suppose I have the following tables:
a = {1, 2, 3, 4, 5, 7, 8}
b = {3, 5, 8, 10, 11, 12}
a AND B in SQL = {3. 5. 8}
a OR B in SQL = {1, 2, 3, 4, 5, 7, 8, 10, 11, 12}
now, A XOR B = {1, 2, 4, 7, 10, 11, 12}
in othe words, the output should give:
ALL but not the ones that are common (All except a AND B).
In SQL 2005; I can do it, but probably in access is totally different:
CREATE TABLE a ( col int )
GO
INSERT INTO a VALUES (1)
INSERT INTO a VALUES (2)
INSERT INTO a VALUES (3)
INSERT INTO a VALUES (4)
INSERT INTO a VALUES (5)
INSERT INTO a VALUES (7)
INSERT INTO a VALUES (8)
GO
CREATE TABLE b ( col int )
GO
INSERT INTO b VALUES (3)
INSERT INTO b VALUES (5)
INSERT INTO b VALUES (8)
INSERT INTO b VALUES (10)
INSERT INTO b VALUES (11)
INSERT INTO b VALUES (12)
-- a AND B in SQL = {3. 5. 8}
SELECT col
FROM a
INTERSECT
SELECT col
FROM b
-- a OR B in SQL = {1, 2, 3, 4, 5, 7, 8, 10, 11, 12}
SELECT col
FROM a
UNION
SELECT col
FROM b
(SELECT col FROM a UNION SELECT col FROM b)
EXCEPT
(SELECT col FROM a INTERSECT SELECT col FROM b)
pleeeze, only a hint.
--
Thanks,
Rick.
"For every problem, there is a solution that is simple, neat, and wrong."
H. L. Mencken"