我有以下表格;
A B A B
_____ _____
1 t 7 a
2 r 5 d
3 e 3 e
4 f
5 d
6 s
7 a
而且,输出应该是;
A B
_____
1 t
2 r
4 f
6 s
换句话说,我想要这两个表的区别。我希望this figure中的区域A. 我怎么能这样做?
答案 0 :(得分:4)
试试这个:
SELECT t1.*
FROM t1
LEFT JOIN t2 USING (A, B)
WHERE t2.A IS NULL
答案 1 :(得分:2)
不使用JOIN
SELECT A, B
FROM tableA
WHERE A NOT IN
(SELECT Distinct A FROM tableB)
答案 2 :(得分:0)
这应该可以解决问题:
SELECT
A,
B
FROM Table_1
WHERE NOT EXISTS
(
SELECT Table_2.A AS Test
FROM Table_2
INNER JOIN Table_1 AS T ON Table_2.A = Table_1.A
)
答案 3 :(得分:0)
SELECT A, B
FROM Table1
EXCEPT
SELECT A, B
FROM Table2;