declare @a table(aid int ,avalue int)
insert @a select 1,2 
declare @b table(bid int ,aid int ,addvalue int ,isadd int)
insert @b select 1,2,3,4 
declare @c table(bid int)
insert @c select 1
-->1
update b set isadd=1 from @b b,@c c where b.bid=c.bid 
-->2
update a set a.avalue=a.avalue+b.addvalue from @a a,@b b where a.aid=b.bid

解决方案 »

  1.   

    @wufeng4552
    第二条是在第一条的基础上,意思是说 bid必须在c表中可以找到,并且  b表-a表是 多对一的关系;c表-b表是1对1的关系
      

  2.   

    谢谢大家 已搞定
    UPDATE a SET avalue =(avalue+cast((SELECT sum(oam.addvalue) AS addValue
     FROM b oam INNER JOIN c ON c.bid=oam.bid GROUP BY oam.aid) AS int))
    可惜能在vs2005里边调试成功,在查询分析器里出错。。