怎么又出来个表3?
是不是如下:
update a set a.qty1 = a.qty1 + b.qty2
from 表1 a
join 表2 b on a.idno = b.goodsid
是不是如下:
update a set a.qty1 = a.qty1 + b.qty2
from 表1 a
join 表2 b on a.idno = b.goodsid
调试欢乐多
from 表1,表2
where 表1.idno=表2.goodsid
from 表1 inner join 表2 on 表1.idno=表2.goodsid
where 表1.idno=表2.goodsid
from 表1 a inner join(select 物料号,数量=sum(数量) from 表2 group by 物料号) b on a.货品号=b.物料号
from 表1 a inner join(select 物料号,数量=sum(数量) from 表2 group by 物料号) b on a.货品号=b.物料号
create table table4(c varchar(20),d int);
insert into table3 values('a',1);
insert into table3 values('b',10);
insert into table3 values('c',15);
insert into table3 values('d',80);
insert into table3 values('h',90);insert into table4 values('a',100);
insert into table4 values('c',150);
insert into table4 values('a1',10);
insert into table4 values('a2',10);
insert into table4 values('a',50);
insert into table4 values('a',50);
insert into table4 values('h',50);
insert into table4 values('h',50);update table3 set b=ISNULL((select sum(d) from table4 where table4.c=table3.a),0)+b;
http://expert.csdn.net/Expert/topic/2168/2168349.xml?temp=.9867517