I want to update each row of a oracle table based on another table's rows. To be more specific, There's a table called Contact with the following fields:

 code(PK), name, mobile, email

There's also another table called Contact_Updated with same fields. The question is how to update Contact records with their equivalent in Contact_Updated table?

any idea?

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

Something along the lines of:

MERGE INTO Contact a
  USING Contact_Updated b
    ON (a.code = b.code)
  WHEN MATCHED THEN  /* no NOT MATCHED clause, so no inserts, update only */
    UPDATE SET a.name = b.name,  a.mobile=b.mobile,  a.email=b.email;
link|improve this answer
Thanks kubanczyk, it worked! – Mehdi Es-haghi Feb 11 at 5:08
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.