mysql replace into duplicates rows code example
Example 1: mysql remove duplicates
DELETE FROM table_name WHERE id
NOT IN ( SELECT id FROM table_name
GROUP BY field_1, field_2)
Example 2: mysql on duplicate key update
INSERT INTO t1 (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=3;
INSERT INTO t1 (a,b,c) VALUES (4,5,6)
ON DUPLICATE KEY UPDATE c=9;