update  (select a.id,a.quantity as quantitya,b.quantity as quantityb from a,b
where a.id=b.id) set quantitya=quantitya-quantityb

解决方案 »

  1.   

    参考下例:改成你要的就行了.
    UPDATE aa_a  t SET t.price=(SELECT a.price-b.price FROM aa_a a,aa_b b WHERE a.col_a=b.col_a AND a.col_a=t.col_a)
      

  2.   

    update a set quantity=(select quantity from b where a.id=b.id) where exists(select 1 from b where a.id=b.id)
      

  3.   

    update A t set t.QUANTITY=(SELECT a.QUANTITY-b.QUANTITY FROM A a,B b WHERE a.id=b.id AND a.id=t.id)
      

  4.   

    update a set quantity=(select a.quantity-quantity from b where a.id=b.id) where exists(select 1 from b where a.id=b.id)上面写错了
      

  5.   

    SQL> select * from a;         ID    QUANTITY
    ----------- -----------
              1          10
              2          10
              3          10
              4          10
              5          10
              6          10
              7          107 rows selectedSQL> select * from b;         ID    QUANTITY
    ----------- -----------
              1          10
              3          10
              5          10
              7          10
    SQL> update a set quantity=(select a.quantity-quantity from b where a.id=b.id)
      2  where exists(select 1 from b where a.id=b.id);4 rows updated
    SQL> select * from a;         ID    QUANTITY
    ----------- -----------
              1           0
              2          10
              3           0
              4          10
              5           0
              6          10
              7           07 rows selected