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

比较过滤得有关问题

2012-03-14 
比较过滤得问题,一个表table字段1字段2A1B1C1D1A2X2Y2B2Z2从这里找出X2Y2Z2怎么做?[解决办法]selectt.*fro

比较过滤得问题,
一个表table
字段1     字段2
A               1
B               1
C               1
D               1
A               2
X               2
Y               2
B               2
Z               2

从这里找出
X               2
Y               2
Z               2
怎么做?

[解决办法]
select
t.*
from
[table] t
where
t.字段2=2
and
not exists(select 1 from [table] where 字段1=t.字段1 and 字段2=1)
[解决办法]
select * from [table] a where not exists(select 1 from [table] b where a.字段1=b.字段1 and b.字段2=1)

热点排行