SQL可以实现这个功能吗?麻烦各位高手解答

来源:百度知道 编辑:UC知道 时间:2024/06/09 02:44:50
假设我有下面这样一个表A
a b
1 1
1 2
1 3
1 4
1 5
只要我的b字段里有4和5,那所有a字段里的1都不显示出来.有这样的语句吗?求助高手.
有表A
a b c
1 2 1
1 3 1
1 4 1
1 5 1
2 1 1
2 2 1
2 3 1
2 6 1
3 1 1
3 4 1
3 5 1
我要的结果是:
a c
2 1
不知道这样大家明白了没有?......

select distinct a,c from A Where a not in (Select distinct a From A Where b='4' or b='5')

没有明白你要做什么!

select b from A where b between '4' and '5'

可以了,一般的SQL是那种版本,一般2000有多的 ,处理数据够 了

就是只要b这个字段等于4,5就不显示这行记录
select * from a where b <> 4 and b <> 5

把数据帖出来,你要的结果也帖出来,这样别人才明白 你的问题

select case (select count(*) from a where b = 4 or b = 5)
when 0 then
a
else
''
end as a, b
from a

select * from 表名称 where a=2 and (b=4 or b=5)