1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| CREATE TABLE T1 (a1 int, b1 int, c1 int)
CREATE TABLE T2 (a2 int, b2 int, c2 int)
CREATE TABLE T3 (a3 int, b3 int, c3 int)
INSERT INTO T1 VALUES (1, 1, 1)
INSERT INTO T1 VALUES (2, 2, 2)
INSERT INTO T1 VALUES (3, 3, 3)
INSERT INTO T1 VALUES (4, 4, 4)
INSERT INTO T2 VALUES (1, 1, 1)
INSERT INTO T2 VALUES (2, 2, 2)
INSERT INTO T2 VALUES (5, 5, 5)
INSERT INTO T3 VALUES (1, 1, 1)
INSERT INTO T3 VALUES (3, 3, 3)
INSERT INTO T3 VALUES (5, 5, 5)
select a1
from T1
INNER join (SELECT a2 AS A0
FROM T2
UNION
SELECT a3
FROM T3) AS T
ON a1 = A0
a1
-----------
1
2
3 |
Partager