1: 效率高, 连接,update 后跟别名
update a
set a.Field1= b.Field1
from Table1 a
left join Table2 b on a.SID=b.ID
where b.Code like 'm%'
效率高
2: 子查询,update后跟表名
update Table1
set Field1=
(
select Field1 from Table2
where Table2.SID=Table1.ID
)
where exists
(
select *
from Table2 b
where b.ID=Table1.ResourceID and b.Code not like 'm%'
)
效率低,因为每个子查询都要访问Table2