您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
A表(tb_abc):
A | B | |
1 | aa | 0200 |
2 | bb | 0300 |
3 | cc | 0500 |
4 | dd | 1800 |
5 | ee | 2200 |
6 | ff | 3300 |
B表(tb_abcc):
A | B | |
1 | aa | (0201) |
2 | aa | (0202) |
3 | bb | (0301) |
4 | bb | (0302) |
5 | bb | (0303) |
6 | cc | (0501) |
括号里是预期值
规则: 通过B表的a字段匹配A表的a字段,并读取A表的b字段,按照该值依次增数写入B表b字段
实现:
update tb_abcc c set c.b = (select tmp.str from (select b.rowid rd, b.a, substr(a.b, 1, 2) || lpad( ( rank () over (partition by b.a order by b.rowid) ), 2, 0 ) str from tb_abc a, tb_abcc b where a.a = b.a) tmp where c.rowid = tmp.rd) where exists (select 'x' from (select b.rowid rd, b.a, substr(a.b, 1, 2) || lpad( ( rank () over (partition by b.a order by b.rowid) ), 2, 0 ) str from tb_abc a, tb_abcc b where a.a = b.a) tmp where c.rowid = tmp.rd);
6 rows updated
select * from tb_abcc;
A B
---- ------
aa 0201
aa 0202
bb 0301
bb 0302
bb 0303
cc 0501
6 rows selected
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。