读书人

求一简单SQL,该怎么解决

发布时间: 2012-01-20 18:53:53 作者: rapoo

求一简单SQL
表A
FF  GG
5555 1233
5454 2345
1233 2222
2345
2222
我想查出 FF 里 GG里没有的数据.

[解决办法]
select * from a where ff not in (select gg from a)
[解决办法]

create table 表A(FF varchar(100),GG varchar(100))

insert into 表A
select 5555, 1233 union all
select 5454, 2345 union all
select 1233, 2222 union all
select 2345,null union all
select 2222,null

select * from 表A

select * from 表A
where isnull(FF, ' ') not in (select isnull(GG, ' ') from 表A)


drop table 表A

读书人网 >SQL Server

热点推荐