表A记录
id | email 1 | abc@abc.com 2 | xyx@xy.com 3 | kkdk@kk.com 4 | 333@abc.com
表B记录
id | email 1 | abc@abc.com 3 | kkdk@kk.com
现在结果应该是
id | email 2 | xyx@xy.com 4 | 333@abc.com
如何使用连接执行此操作?
答案 0 :(得分:1)
尝试类似:
SELECT
t1.*
FROM tableA as t1
LEFT JOIN tableB t2 ON t1.email=t2.email
WHERE t2.id IS NULL
答案 1 :(得分:1)
试试这个:
select distinct(a.id), a.email from table1 a inner join table2 b
on a.id not in (select id from table2)
答案 2 :(得分:0)
尝试左连接并检查tableB id为null的位置。
select tableA.* from tableA left join tableB on tableA.email = tableB.email
where tableB.id is null