在帖子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的呀?
 

解决方案 »

  1.   

    select  1 和  select count(×) 是一个效果
      

  2.   

    不好意思  LZselect 1 是和  select * 一个意思
      

  3.   

    select  1  from  dual  
      where  exists  (select  1  from  a,b  where  a.id=b.id  and  ...); 该语句 只判断是否存在 你制定的条件, 不统有多少条记录满足你制定的条件。
    换句话说就是只要扫描到一条 满足指定条件的记录就会返回查询结果。
      

  4.   

    select count(*)
    from (select  1  from  dual  
      where  exists  (select  1  from  a,b  where  a.id=b.id  and  ...));