insert A (price) (select price from B inner join A on A.code=B.code)
?

解决方案 »

  1.   

    update a set price=b.price
    from a join b on a.code=b.code
    where a.price is null
      

  2.   

    update A set A.price =B.price 
    from B.price
    where  a.code=b.code  -----如果全部更新A表中的PRICE字段就写到这里结束 
    and a.price is null   ------如果只更新表A中空price就加上这一句
      

  3.   

    表A是产品表 (id,code,name)
    表B是产品价格表 (id,productid,price)
    表C是产品价格表 (id,code,price)表C只知道产品的CODE,并不知道产品的id
    每个表的ID是自动生成的记录唯一标记,主键
    现在是往B表新建记录,条件是A.code=C.code, A.id=B.productid
    那SQL怎么写
    insert B (productid,price) value (A.code,C.price)