首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sqlserver 与此同时更新一张表的多个列

2013-10-27 
sqlserver 同时更新一张表的多个列?UPDATE tablename1? ?SET?? tablename1 .JLDQCYE tablename2.QC? ,??

sqlserver 同时更新一张表的多个列

?UPDATE tablename1?
?SET?? tablename1 .JLDQCYE = tablename2.QC? ,

?????????? tablename1.JLDBQZJ = tablename2.ZJ ,

?????????? tablename1.JLDQMYE= tablename2.QM???????
?FROM
???? (
???????? SELECT * FROM (
???SELECT B.JLDNM , SUM(B.QC) QC ,SUM(B.ZJ ) ZJ ,SUM(B.QM) QM?? FROM
????????? (
??????? SELECT C.JLDNM , 0 QC? , 0 ZJ , C.JLDJE QM? FROM VW_ZJGXJLD_JBXX? C WHERE? C.jldqrrq <= '20130930'
????????? ) B GROUP BY B.JLDNM
???????? )? biename1
????? ) tablename2 ,tablename1???????????????????

WHERE tablename2.JLDNM = tablename1.JLDNM?

?

注意点:biename1必须要加(查询出来的结果集要加别名)tablename2 也要加

?

热点排行