首页 > 代码库 > MSSQL update 多表关联更新

MSSQL update 多表关联更新

1 update tMeter set  字段= t.源自段  from (2         select * from 源表信息3 ) t4 where 关联条件

实际demo:

1 UPDATE dbo.WX_TWODIMENCODE_INFO SET 2     wti_scan_views=t.count FROM (3     SELECT COUNT(*) AS count,lci_erector_scene_id FROM LOTTERY_CODE_INFO4        WHERE lci_type=40 AND lci_erector_code_scantime IS NOT NULL5        GROUP BY lci_erector_scene_id6     ) AS t7     WHERE wti_scene_id=t.lci_erector_scene_id

 

MSSQL update 多表关联更新