首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-03-18 
求一条sql语句,2表查询我有两张表tab1,tab2,都有一个name字段要出显示tab1的name字段的结果集,并且结果中

求一条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)

热点排行