kikiboy 发表于 2011-12-22 18:48

Oracle关联update

create table t1(

id number,

name varchar2(10)

);

insert into t1 values(1,'a');

insert into t1 values(2,'b');

insert into t1 values(3,'c');

insert into t2 values(1,'','a1');

insert into t2 values(2,'','b2');

insert into t2 values(3,'','c3');
现在t2表中的name字段要根据t1表中的name更新;

update t2 set name=(select name from t1 where t1.id=t2.id) where   exists (

select id from t1 where t2.id=t1.id);


select * from t2

id name loc

1 a a1
2 b b2
3 c c3

来源:http://blog.chinaunix.net/space.php?uid=15457221&do=blog&id=2853867
页: [1]
查看完整版本: Oracle关联update