MSSQL update 多表关联更新

1 update tMeter set  字段= t.源自段  from (
2         select * from 源表信息
3 ) t
4 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_INFO
4        WHERE lci_type=40 AND lci_erector_code_scantime IS NOT NULL
5        GROUP BY lci_erector_scene_id
6     ) AS t
7     WHERE wti_scene_id=t.lci_erector_scene_id

 

你可能感兴趣的:(update)