本文介绍了如何优化SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
我想优化以下代码

Hello Friends,
I wanted to optimize following code

inner join tbl_planning P on p.iterationid=(select MAX(iterationid) from tbl_iteration  where mechanicalid = B.mechanicalid
and iterationid< B.iterationid and artworktype in (2,5))
OR (
p.mechanicalid = ISNULL((select MAX(iterationid) from tbl_iteration  where mechanicalid = B.mechanicalid
and iterationid< B.iterationid),
(select mechanicalid from tbl_mechanicalbrief MF where MF.mechanicalid=b.mechanicalid)) and jobtype=1)



有什么想法可以优化此联接吗?

在此先感谢



Any idea to optimize this join?

Thanks in advance

推荐答案

select MAX(iterationid) from tbl_iteration  where mechanicalid = B.mechanicalid
and iterationid< B.iterationid)



尝试解决此问题并分开保存



Try to resolve this and hold seperatly


这篇关于如何优化SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 16:19