你想要得结果是否是这样的结果:Field1 Field2 Field3 Field4 3 B 否 4 B 否 5 B 否
select Field1,Field2,Field3 ,Field4 from table where Field3='否' and Field2='B' order by Field2;
select distinct field2 from table_name a where not exists(select field2 from table_name b where field3 = '是' and b.field2 = a.field2 group by field2 ) and field3 <> '是'
to jsnicle(js_nicle)你的语句不行,我要的是 ashg_16700(安) 说得结果, 而且B不是一个定值,不能用not in ,not exists,请大家继续阿!
select Field1,Field2,Field3 ,Field4 from table where Field3='否' and Field2='B' order by Field2; 这个不对吗?????
TO 楼主: 为何不能用not exists?
用not exists 会影响查询的速度.
用not exists 是种低效的方法.
SELECT * FROM TABLE MINUS SELECT * FROM TABLE WHERE Field3='是'
select field2 from table where field3 not like '%是%';
请教Croatia(Croatia) "MINUS"是什么意思,谢谢!!!
select Field1,Field2,Field3 ,Field4 from table where Field3='否' order by Field2;
谢谢大家,to zhaokeke2004(男人·海洋) not in 和not exists 速度太慢 to Croatia(Croatia)你的方法很不错,可惜的是sql server2000中不支持minus阿, 我记得好像有表自连接还是自嵌套可以做,但是我写不出来
not exists可以使用索引Field3加索引就快了
select Field1,Field2,Field3,Field4 from table where isnull(Field3,'')<>'是' order by Field2;
3 B 否
4 B 否
5 B 否
select Field1,Field2,Field3 ,Field4 from table where Field3='否' and Field2='B' order by Field2;
from table_name a
where not exists(select field2
from table_name b
where field3 = '是' and b.field2 = a.field2
group by field2 )
and field3 <> '是'
而且B不是一个定值,不能用not in ,not exists,请大家继续阿!
select Field1,Field2,Field3 ,Field4 from table where Field3='否' and Field2='B' order by Field2;
这个不对吗?????
为何不能用not exists?
MINUS
SELECT * FROM TABLE WHERE Field3='是'
to Croatia(Croatia)你的方法很不错,可惜的是sql server2000中不支持minus阿,
我记得好像有表自连接还是自嵌套可以做,但是我写不出来