#1062 - Duplicate entry indexed_field' for key 2
Mysql will return a duplicate entry error when trying to insert a duplicate value in an indexed field in the database. We could modify our sql insert state to check for primary key duplicate or index field duplicate and automatically update the first field with the updated value like this.
INSERT INTO table1 (a,b,c)
SELECT a,b,c
FROM table2
WHERE a IS NOT NULL
ON DUPLICATE KEY
UPDATE table1.a = table2.a
u guys are the best!