像这样的形式,自己试试
update b set b.name=(select a.name from a where a.id=b.id and a.name='八戒');

解决方案 »

  1.   

    UPDATE TB_1 SET (COL1,COL2,...) = (SELECT (COL1,COL2,...) FROM TB_2 WHERE condition)
    WHERE CONDITION
      

  2.   

    to:ATGC(这一生受了很多委屈吃了很多苦。。) 
       你这好像是一个字段
    to:qiaozhiwei(乔)
       我不知道字段的个数阿,更不知道有多少个字段
    如何写?
      

  3.   

    方法一:(啥都不知道)
    drop table mytab2 cascade constraints;
    create table mytab2 as select * from mytab1;-----------------------
    方法二:(不能删除表2)
    insert into mytab2 select * from mytab1;
    commit;
      

  4.   

    方法三:(清空表2)
    truncate tabel mytab2;
    insert into mytab2 select * from mytab1;
    commit;
    ---------------------
      

  5.   

    如果是数据要覆盖,个人觉得应该这样:1:删除表2中所有符合条件的数据;
      delete from table2 where <条件>2:把符合条件的表1数据插入到表二中;
      insert into table2 select * from table1;
      

  6.   

    这样:
      从t2查询记录到t1中
      insert into t1 select * from t2 where ....(条件) ;
      commit ;
      

  7.   

    to 楼主,
    如果你需要更新的字段相对整个表很多,建议你使用sanoul(垃圾)的方法,
    如果只是若干,你可以用若干个update,如ATGC(这一生受了很多委屈吃了很多苦。。) 所写
      

  8.   

    create table tab1(id varchar2(20),key varchar2(20))create table tab2(id2 varchar2(20),key2 varchar2(20))insert into tab1 values('001','0001')
    insert into tab1 values('002','0002');
    insert into tab1 values('003','0003');
    insert into tab1 values('004','0004');insert into tab2 values('001','00001');
    insert into tab2 values('002','00002');
    insert into tab2 values('003','00003');select * from tab1select * from tab2--错误没有的被更新为null
    update tab1 a
    set key=(select key2 from tab2 b where a.id=b.id2)--正确只有相等才会被更新
    update tab1 a
    set key=(select key2 from tab2 b where a.id=b.id2)
    where exists (select 1 from tab2 b where a.id=b.id2)