exists 和not exists 代替in 和not in

解决方案 »

  1.   

    select * from tablename where (column2=b or column1<>a) and column3 in (c,d,e,f)
      

  2.   

    是我说得太含糊?
    第一个条件是“之外的“,也就是,不能是满足条件(column2=b or column1<>a)
      

  3.   

    select * from table a where 1=1 and (a.column1<>'a' or a.column2<>'b') and a.column3 in ('c','d','e','f')
      

  4.   

    sorry
    select * from table a where 1=1 and (a.column1<>'a' or a.column2='b') and a.column3 in ('c','d','e','f')
      

  5.   

    给你一点做参考,下面的25%是我多次测试过的:
    当程序中用到not in时,用下面的方法代替,效率会提高25%
    select PERMIT.* from PERMIT,WORK_ORDER_PERMIT where PERMIT.permit_seq=WORK_ORDER_PERMIT.permit_seq(+) and WORK_ORDER_PERMIT.permit_seq is null;
      

  6.   

    谢谢dinya2003(OK) ,就用你的方法了。好像其它也没什么颁发了。
    也谢谢楼上的not in 的替代方法,这个外连接的方法好像只适合TABLE 与 TABLE之间的时候。TABLEA.COLUMN1 NOT IN (‘AA’,‘AB’,‘BA’)应该是不能改的吧。。