update table1 set myname = (select table2.myname from table2 where table1.mycode = table2.mycode)
where exists(select 1 from table2 t2 where table1.mycode = t2.mycode);
truncate table z执行清表操作;如果两个表的记录数原来就不一致,是不能这样做的.
看来还是用楼上的方法较好:
update table1 set myname = (select table2.myname from table2 where table1.mycode = table2.mycode)
where exists(select 1 from table2 t2 where table1.mycode = t2.mycode);