我现在没环境测试,你测测吧
update table2 set 采购数量=
( select sum(进货数量)
  from table1 where  进货日期 >= 上月同日 and 进货日期 < today
  and table1.id = table2.id )

解决方案 »

  1.   

    应该在最后还应该有个WHERE来限定你的TABLE2更新的记录
      

  2.   

    按题目意思
    在采购计划表table2 中应该没有 在  进货表table1
    不存在的
    商品id   若有 可加如下条件
    where id in ( select unique id from table1 ) 
      

  3.   

    insert into table2 select id,sum(进货数量)
      from table1 where  进货日期 >= 上月同日 and 进货日期 < today
      group by id