美文网首页
sql两个表的差

sql两个表的差

作者: 山的那边是什么_ | 来源:发表于2017-12-04 16:58 被阅读58次

有两个表t1和t2,表中只有一个字段c1。
求两个表的差。即存在于t1,但不存在于t2中的记录。

select c1 from t1 where c1 not in (select c1 from t2)
select c1 from t1 where not exists(select * from t2 where t1.c1=t2.c1)
select t1.c1 from t1 left join t2 on t1.c1=t2.c1 where t2.c1 is null

相关文章

网友评论

      本文标题:sql两个表的差

      本文链接:https://www.haomeiwen.com/subject/nbvxixtx.html