sql查询两表中不重复记录

来源:百度知道 编辑:UC知道 时间:2024/05/20 19:43:13
两个表中有很多重复的记录,我只想找到其中某一个表中与另一个表中不重复的那部分。谢谢

select * from table1 where not exists (select 1 from table2 where 关键字=table1.关键字);

举个例子你看看:
SELECT * from A where phoneno not in(select phoneno from B)其中phoneno是在两个表中都存在的字段。

select * from A where id not in (select id from B)