【转】MySQL 与MS SQL Server数据库使用多表关联Update时语法的区别

我们经常会遇到需要将一个表中某些字段的值批量更新到另一个表的对应记录下的对应字段中去的情况。

MS SQL Server的语法:
update t1 set t1.tValue = t2.tValue
from t1
inner join t2 on t1.id = t2.id
例子:
update area
set area_phone_code = z.code
from area
inner join test.zipcode z
on z.areaid = a.area_code
MySQL的语法:
update table1 t1 ,table2 t2 set t1.tValue =t2.tValue where t1.id=t2.id
例子:
update area a, test.zipcode z
set a.area_phone_code = z.code
where z.areaid = a.area_code
两种数据库在这个语法上面差异还是很大的。
原文地址:https://www.cnblogs.com/abinxm/p/2107947.html