这句话没看懂:   rq为当日日期的sale相应的值

解决方案 »

  1.   

    供参考:
    更改P表中的name,条件是id和category相等
    MERGE INTO products p   
    USING newproducts np   
    ON (p.product_id = np.product_id)   
    WHEN MATCHED THEN  
    UPDATE  
    SET p.product_name = np.product_name   
    WHERE p.category = np.category;
      

  2.   

    merge into biao2 b2
    using biao1 b1
    on (b1.id_man=b2.id_man)
    when matchd then
    update set
     b2.sale =b1.sale 
      

  3.   

    update biao2 b2 set b2.sale =(select b1.sale from biao1 b1 where b1.id_man =b2.id_man)
    如果条件再严格一点,再加上
    where b1.id_man in (select id_man from biao2)
      

  4.   

    利用biao1中id_man值相同(即biao1.id_man=biao2.id_man) 且biao.rq为当日日期的bioa1.sale相应的值。
    来更新biao2中的sale值。
    楼上的回答都漏了一个要求。且biao.rq为当日日期
      

  5.   

     update biao2 b 
     set b.sale=(select nb.sale from (select b1.id_man,b1.sale from biao1 b1 join biao2 b2 on b1.id_man=b2.id_man where to_char(b1.rq,'yyyy-mm-dd')=to_char((select sysdate from dual),'yyyy-mm-dd')) nb where b.id_man=nb.id_man);注意如果biao1没有biao2的id_man
      

  6.   

    declare 
      cursor cur_aa is select * from biao1;
    begin
      for cur_a in cur_aa
        update biao2 set ... where id_man=cur_a.id_man and trunc(b1.rq)=trunc(sysdate);
      end loop;
    end;--It is a demo .
    --if undo and temp tablespace are enough ,sql is more efficient than plsql
      

  7.   

    And don't forget to commit partly when the rows is large.
      

  8.   

    merge into biao2 b2
    using (select * from biao1 where trunc(rq)=trunc(sysdate)) b1
    on (b1.id_man=b2.id_man)
    when matchd then
    update set b2.sale =b1.sale;