1.a表 id(主键),name varchar2(30)
  b表  id2 ,name2
 问题:把a表中所有name重复的记录插入b表中。
2. a表 aid,aemail
  b表  bid,bemail
 aid和bid关联,把b表中的emai更新为a表中的email。

解决方案 »

  1.   

    1insert into b select * from a where a.id in(select id,count(name) from a group by id having count(name)>1)
      

  2.   

    update b set bemail=(select aemail from a where a.aid=b.bid)
      

  3.   

    insert into b select * from a where a.name in(select name,count(id) from a group by name having count(id)>1)
      

  4.   

    update b set bemail=(select aemail from a where a.aid=b.bid)
    where exist(
    select 1
    from a
    where a.aid=b.bid
    )