日期:2014-05-17 浏览次数:20572 次
SELECT A.* FROM tw_tb AS A
LEFT JOIN tw_tb2 AS B ON A.name=B.name
WHERE B.name IS NULL
SELECT * FROM tw_tb WHERE NOT EXISTS
(SELECT * FROM tw_tb2 WHERE tw_tb.name=tw_tb2.name)
--举个例子,自己看看结果
if object_id('a') is not null
drop table a
create table a
(
id int primary key identity(1,1),
name nvarchar(20)
)
go
insert into a
select '张三' union all
select '李四' union all
select '王五' union all
select '赵六' union all
select '' union all
select null union all
select '孙七'
go
select * from a
select * from a where name is not null
select * from a where name is null
select * from a where name = ''