select b.intmkid from (select swcdmk.intmkid,swcdmk.chrispd  
from swcdmk,(select swcdmk.chrmkccbm from swcdmk where swcdmk.chrmkmc='公文查询' and swcdmk.chrmklx='1') 
a where swcdmk.chrmklx='1' and substr(swcdmk.chrmkccbm,1,length(a.chrmkccbm))=a.chrmkccbm) b,swyhcdmk 
where (b.chrispd is null or b.chrispd!='1') or (swyhcdmk.chryhm='lgj' and swyhcdmk.intmkid=b.intmkid)语句不能改的

解决方案 »

  1.   

    首先,你的语句中存在问题
    b.chrispd is null or b.chrispd!='1'
    这个语句完全可以将b.chrispd is null去掉,b.chrispd is null已经包含在b.chrispd!='1'的条件中了,所以,这个条件是根本没有必要的,无论你是在sql server还是在oracle中执行。
    关于效率,你可以看看字段swyhcdmk.chryhm 和字段swyhcdmk.intmkid上是否有索引存在。
    你可以先看看执行计划,然后调整索引等
      

  2.   

    本人水平有限,一下想不到
    zakat(听者如歌) 说的我基本同意
    但将b.chrispd is null去掉这是不对的
      

  3.   

    同意 xiandaishihou(xiandaishihou) ,is null 是不能去掉的,抱歉