当前位置: 代码迷 >> Sql Server >> 求一简单SQL,该怎么解决
  详细解决方案

求一简单SQL,该怎么解决

热度:64   发布时间:2016-04-27 21:25:40.0
求一简单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
  相关解决方案