I'm using mysql database. I'm having a main table with id as primary key with (auto increment,not null, unique) constraints.
My main table :
In secondary table i have the same fields but without id column
Now i need to update the main table from the secondary table with the following condition.
if a user data exists in main table, it should be replaced with secondary table data and new rows should add. (example: 1st row of user1 needs to be replaced with secondary table data , and new rows of user1 should be added in the main table)
Expected output:
I have tried with insert...on duplicate update. it doesn't worked ! Any help?