INSERT ON DUPLICATE KEY UPDATE in MySQL
INSERT ON DUPLICATE KEY UPDATE statement in MySQL is used to handle duplicate entries on a primary key or unique column. This statement works like a normal INSERT statement until a duplicate value is inserted in a primary key column.
When a duplicate value is entered in the primary key column, it raises an error. But the ON DUPLICATE KEY UPDATE clause handles this error by updating the row of the Primary key column.
MySQL INSERT ON DUPLICATE KEY UPDATE Statement
MySQL INSERT ON DUPLICATE KEY UPDATE statement is an extension to the INSERT statement, that if the row being inserted already exists in the table, it will perform a UPDATE operation instead.