SQL update和select语句合并
declare @id int set @id=64 update formtable_main_258 set yxzsum=(select sum(yxz) from formtable_main_258_dt1 a where a.mainid=@id),txyxzsum=(select SUM(yxz) from formtable_main_258_dt1 where mainid=@id AND qrtzfd<>0 AND qrtzfd IS NOT NULL) where id=@id
需要更新数据库表2两列yxzsum,yxzsumtx,值是表1字段yxz的求和,txfd!=0的yxz求和
数据不多 直接定义一个id 函数,更改id赋值,如果要多行数据更新,用for循环可否
 
                    
                
 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号