1
MERGE emp_old AS T USING emp_new AS S
    ON T.e_id=S.e_id
WHEN MATCHED THEN UPDATE SET T.e_age=S.e_age, T.e_salary=S.e_salary
WHEN NOT MATCHED BY TARGET THEN INSERT (e_id,e_name,e_salary, e_age, e_gender, e_dept)
    VALUES(S.e_id,S.e_name,S.e_salary,S.e_age,S.e_gender,S.e_dept)
WHEN NOT MATCHED BY SOURCE THEN DELETE;

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MERGE emp_old AS T USING emp_new AS S ON T.e_id=S.e_id WHEN MATCHED THEN UPDA' at line 1

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149

0 Answers0