如何使用表连接优化此查询?

时间:2014-04-07 11:16:32

标签: sql optimization join

有人可以帮我优化以下查询...

UPDATE tab1 SET col1 = 'NA' where 
col2 =(Select col1 from tab2 where col2 is null and 
col3 = (Select col1 from tab3 where col2 = 100));

1 个答案:

答案 0 :(得分:0)

update t1
SET col1 = 'NA'
from tab1 t1
inner join tab2 t2 on t1.col2=t2.col1 and t2.col2 is null
inner join tab3 t3 on t2.col3=t3.col1 and t3.col2 = 100