将A表的a字段值=1的b字段的和插入到B表中c字段=2的d字段中。
这个SQL语句怎么写。

解决方案 »

  1.   

    select 表1.a1,表1.b1,表2.*,表1.a1+表1.b1 as d2 from 表1,表2 where 表1.a1=1 and 表2.c2=3;表结构
    表1:
    a1,b1,c1
    1   1   1
    2   2   2
    3   3   3
    表2:
    a2,b2,c2
    2   2  2
    3   3  3  
    4   4  4
    结果:
    a1,b1,a2,b2,c2,d2
    1   1  2  2  2  2
      

  2.   

    declare @sum intset @sum=select sum(b) from A where a=1update b set d=@sum where c=2