需要考虑的语句
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和<>有这么大的差别?
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和<>有这么大的差别?
相关文章推荐
- 32位程序移植到64位需要考虑的问题
- 项目成本管理需要考虑哪些方面
- 编写测试用例需要考虑的一些因素
- 经营一个优秀网站需要考虑的问题
- 如果网页内容需要支持多语言,你会怎么做?在设计和开发多语言网站时,有哪些问题你必须要考虑?
- Asp.net 2.0的异常处理需要考虑的问题
- javascript Array.sort() 跨浏览器下需要考虑的问题
- 在书写高效 CSS 时会有哪些问题需要考虑?
- 数据库服务器升级内存需要考虑的问题
- 使用Singleton需要考虑内存释放
- 增加友链需要考虑哪些因素
- [html] 前端角度出发做好SEO需要考虑什么
- SAP项目分阶段实施需要考虑的因素
- 组建大型机群系统需要考虑的一些问题
- 做网站需要考虑的事情
- 使用MyBatis一次执行多条SQL语句,需要配置jdbc连接串
- CIO们需要从战略层面出发考虑云计算
- 为台式电脑购买无线网卡设备需要考虑的几点
- 测试设计中需要考虑的22种测试类型
- Oracle12C--此专栏的SQL所需要的建表语句(一)