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

求一简单SQL,该怎么解决

2012-01-20 
求一简单SQL表AFF  GG55551233545423451233222223452222我想查出 FF 里 GG里没有的数据.[解决办法]select

求一简单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

热点排行