卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章11201本站已运行3223

sql两个求表的差语法

sql求两个表中t1和t2,表中只有一个字段c1。

求两个表的差。即存在于t1,但不存在于t2中的记录。

方法1.

select c1 from t1 where c1 not in (select c1 from t2)

方法2.

select c1 from t1 where not exists(select * from t2 where t1.c1=t2.c1)

方法3.

select t1.c1 from t1 left join t2 on t1.c1=t2.c1 where t2.c1 is null

卓越飞翔博客
上一篇: SQL求和语法详解
下一篇: 常用sql操作数据库语法总结
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏