Domanda

I am trying to merge two tables but I'm new to the merge function

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)

I want ppltr to have all the username values from poant using merge, can anyone advise on how I can get this done?

È stato utile?

Soluzione

Try this:

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;

Altri suggerimenti

Try this. Correct isome minor syntax errors if it has:

 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 );
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top