您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

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

bubuko 2022/1/25 20:05:32 sqlserver 字数 676 阅读 976 来源 http://www.bubuko.com/infolist-5-1.html

方法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= ...

方法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效率高些。

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

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


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶