日期:2014-05-18 浏览次数:20547 次
update t1 set t1.a02=t2.b02 from a t1,b t2 where t1.a01=t2.b02
------解决方案--------------------
DROP TABLE A DROP TABLE B CREATE TABLE A ( a01 INT, a02 VARCHAR(10) ) INSERT INTO A SELECT 1,'haha' UNION ALL SELECT 2,'gaga' UNION ALL SELECT 3,'jiji' CREATE TABLE B ( b01 INT, b02 VARCHAR(10) ) INSERT INTO B SELECT 1,'cc' UNION ALL SELECT 2,'dd' SELECT * FROM A SELECT * FROM B UPDATE A SET A.a02=B.b02 FROM A,B WHERE B.b01=A.a01 SELECT * FROM A /* a01 a02 ----------- ---------- 1 cc 2 dd 3 jiji (所影响的行数为 3 行) */