sqlserver 更新同一个表的不同字段

方法1:

update address set city_name= b.county_name from address,address b where (LEFT(address.address_code,4)=LEFT(b.address_code,4) and b.address_type=2 and address_type=3)

方法2:

update address set city_name=(select top 1 county_name from address b where LEFT(b.address_code,4)=LEFT(address.address_code,4) and b.address_type=2 ) where address_type=3

方法1效率高些。

原文地址:https://www.cnblogs.com/net5x/p/12496646.html