首页 > 代码库 > MS SQL update set select
MS SQL update set select
有张表a,已经有数据
再有张表b,也已查询出数据
两张表有外键关联
需求如下:
更新表a中的某个字段,这个字段要加上(都是int型的数据)对应表b中的数据作为更新的最终数据
update #libList set actiCount=ISNULL(actiCount,0)+ ISNULL(total,0) from #libList left join T on #libList.id= T.libraryid
"total"中是T表中的字段,isnull表示如果没有关联到,则使用0
MS SQL update set select
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。