Oracle数据库一对多联表更新

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_40931184/article/details/84942100

---创建表,模拟数据
create table test(
id varchar(32),
name varchar(32)
);
insert into test(id,name) values('1','张三');
insert into test(id,name) values('2','李四');
insert into test(id,name) values('3','王五');

drop table test1;
create table test1(
id varchar(32),
name varchar(32),
age varchar(32)
);
insert into test1(id,name,age) values('1','','23');
insert into test1(id,name,age) values('1','','23');
insert into test1(id,name,age) values('3','','23');
----开始试验 表之间的字段更新-----
UPDATE test1  SET (NAME) = (SELECT NAME FROM
(SELECT test1.ROWID RD, test.NAME, test.ID FROM test, test1 WHERE test.ID = test1.ID)
TMP WHERE test1.ROWID = TMP.RD);

alter table test add sonCount varchar(32);
----联表更新数量 待补充----

猜你喜欢

转载自blog.csdn.net/weixin_40931184/article/details/84942100
今日推荐