当前位置: 代码迷 >> Sql Server >> 求一条sql语句,2表查询解决方法
  详细解决方案

求一条sql语句,2表查询解决方法

热度:42   发布时间:2016-04-27 16:52:03.0
求一条sql语句,2表查询
我有两张表tab1,tab2,都有一个name字段
要出显示tab1的name字段的结果集,并且结果中不能包含tab2的name字段的值

------解决方案--------------------
select * from tab1 where name not in (select name from tab2)
select * from tab1 where not exists(select 1 from tab2 where name=tab1.name)
------解决方案--------------------
select a.name
from tab1 a
where a.name not in (select name from tab2)
  相关解决方案