您的位置:首页 > 其它

需要考虑的语句

2013-09-12 14:28 183 查看
declare @emp_Code as nvarchar(10)

set @emp_Code='00131'

select s.*,a.audit_Date as lastaudittime,enmName=(select empName from emp where empCode=s.emp_Code),0 as isEnbled from (select id from audit_main where
emp_code=@emp_Code or type in(186,209,231)  union select main_id as id from audit_Sub where
audit_empCode=@emp_Code union select main_id as id from audit_Sub_Emp where
audit_Emp_Code=@emp_Code

  as t inner join audit_Main as s  on t.ID = s.ID inner join audit_sub as a on   s.lab_complete =1 and s.type in(1,4,0,3,10,11,12,13,14,5,6,2,7,51,52,150,152,200,168,151,153,157,162,159,160,161,158,163,164,165,166,167,156,154,155,169,171,170,173,172,174,175,176,177,178,15,180,181,182,183,184,185,186,187,188,189,191,192,190,193,194,195,196,197,198,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240)
and a.ID =s.cur_Sub_id

   and (a.isPass in(1,3,4))  使用这句需要1秒

    --and (a.isPass <>2) 使用这句需要2秒

 and  isnull(s.isDisannuled,0)=0

 

难道in和<>有这么大的差别?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: