se lect max(netdate),min(netdate) fr om te w here  fc in(fc='050001')se lect max(netdate),min(netdate) fr om te w here  exists (sel ect 1 from dual where fc='050001' )

解决方案 »

  1.   

    要看你比较表的数据,如果比较表数据小,是IN会快点,如果数据多,是EXISTs好点
    多数情况下,用exists会有改善
      

  2.   

    语句都错了哦select max(netdate), min(netdate) from tt where fc in ('050001');select max(netdate), min(netdate)
      from tt
     where exists (select 1 from dual where fc = '050001');
    从语句上来看,因该是第一个更好些。因为fc就一个值可取,效率跟fc='050001'差不多。
    第二个还要判断dual嵌套,所以第一个要高些
      

  3.   

    如果in后面跟的不是子查询,是一批固定的值,和or是一样的,能用到索引,速度也快
      

  4.   

    一般情况下:
    in和exists的SQL执行效率分析  A,B两个表,  (1)当只显示一个表的数据如A,关系条件只一个如ID时,使用IN更快:  select * from A where id in (select id from B)  (2)当只显示一个表的数据如A,关系条件不只一个如ID,col1时,使用IN就不方便了,可以使用EXISTS:  select * from A  where exists (select 1 from B where id = A.id and col1 = A.col1)  (3)当只显示两个表的数据时,使用IN,EXISTS都不合适,要使用连接:  select * from A left join B on id = A.id  所以使用何种方式,要根据要求来定。
    我也是从网上拿过来的 希望对你有用啦。
    http://www.cnblogs.com/diction/archive/2008/01/18/1043844.html
    有空去顶下原作者。