在帖子http://topic.csdn.net/t/20051111/15/4387478.html中
KingSunSha(弱水三千)的回复:
select 1 from dual
where exists (select 1 from a,b where a.id=b.id and ...);
可以大幅度提高查询效率。
我有点不明白,该语句怎么统计count(*) ,执行的结果是1的呀?
KingSunSha(弱水三千)的回复:
select 1 from dual
where exists (select 1 from a,b where a.id=b.id and ...);
可以大幅度提高查询效率。
我有点不明白,该语句怎么统计count(*) ,执行的结果是1的呀?
where exists (select 1 from a,b where a.id=b.id and ...); 该语句 只判断是否存在 你制定的条件, 不统有多少条记录满足你制定的条件。
换句话说就是只要扫描到一条 满足指定条件的记录就会返回查询结果。
from (select 1 from dual
where exists (select 1 from a,b where a.id=b.id and ...));