例子:
   a表  字段 id   price
   b表 字段 id    num
 
我想  把a表中的price update为 a.price*b.num where a.id=b.id
 这个sql语句怎么写?
以前在sql server中写过,但在oracle中 有问题?

解决方案 »

  1.   

    update a
       set a.price = (select a.price*b.num from b where a.id = b.id);试试看~~
      

  2.   

    update a 
       set a.price = (select a.price*b.num from b where a.id = b.id)
    where exists 
    (select '1' from b where a.id=b.id); 
      

  3.   

    如果B表中id字段是主键,那么还可以写为
    update (select a.id,a.price,b.num from a,b where a.id=b.id) set price=price*num