I know that I can use UPDATE IGNORE
to pass on whether there is a duplicate key. How would I use the following syntax to do the same?
INSERT INTO table ON DUPLICATE KEY *do nothing*
I know that I can use UPDATE IGNORE
to pass on whether there is a duplicate key. How would I use the following syntax to do the same?
INSERT INTO table ON DUPLICATE KEY *do nothing*
You do it the exact same way.
INSERT IGNORE INTO table ....
That will silently skip any constraint violations. For a bulk insert (eg insert ignore into table select ... from ...
), this will skip the rows that violate a constraint, but continue to insert all rows that can be.
Useful for duplicate removal.