表 :属性
shopcart: id,productid,count...
product: id,salecount...shopcart.productid与product.id对应怎么实现 将shopcart.count加到与之对应的product.salecount上
另:再加个条件shopcart.orderid = onevalue (常量-要处理的订单值)

解决方案 »

  1.   

    XD,  不知道你是加上原有的还是更新 ...如果是Add:update product p
       set p.salecount = s.count+p.salecount
     where exists (
                   select s.count
                     from shopcart s
                    where s.orderid = &onevalue
                      and p.id = s.productid
                  );
    如果是update:update product p
       set p.salecount = s.count
     where exists (
                   select s.count
                     from shopcart s
                    where s.orderid = &onevalue
                      and p.id = s.productid
                  );
      

  2.   

    update product p set p.salecount = s.count+p.salecount where exists ( select s.count from shopcart s where p.id = s.productid )
                                       *
    ERROR 位于第 1 行:
    ORA-00904: "S"."COUNT": 无效的标识符不行 2张表 不知道怎么操作
      

  3.   

    update product p set p.salecount = s.count+p.salecount where exists ( select 1 from shopcart s where p.id = s.productid);再试试看~~~
      

  4.   

    谢谢 
    不过还是这个错误 * 还是在前面那个s.count下面 无法识别ERROR 位于第 1 行:
    ORA-00904: "S"."COUNT": 无效的标识符