我正在尝试合并两个表,但我是合并函数的新手
ppltr
pltr_seqn_num pltr_user
1
2
3
4 Chris
poant
poat_pltr_seqn_num poat_user
2 Sam
3 Dave
4 Chris
merge into ppltr a
using poant b
on (a.pltr_seqn_num=b.poat_pltr_seqn_num)
when not matched then insert(a.pltr_user) values (b.poat_user)
我希望ppltr使用merge来获取poant的所有用户名值,有人可以建议我如何完成这项工作吗?
答案 0 :(得分:1)
试试这个:
MERGE INTO ppltr a USING poant b ON (a.pltr_seqn_num=b.poat_pltr_seqn_num)
WHEN MATCHED THEN
UPDATE SET a.pltr_user = b.poat_user;
答案 1 :(得分:1)
试试这个。正确的isome次要语法错误,如果它有:
MERGE INTO ppltr a
USING (SELECT poat_pltr_seqn_num, poat_user FROM poant) b
ON (a.pltr_seqn_num = b.poat_pltr_seqn_num)
WHEN MATCHED THEN
UPDATE SET a.pltr_user = b.poat_user
WHEN NOT MATCHED THEN
INSERT (a.pltr_seqn_num , a.pltr_user )
VALUES (b.poat_pltr_seqn_num, b.poat_user );