1

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*
David542
  • 104,438
  • 178
  • 489
  • 842

1 Answers1

4

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.

pala_
  • 8,901
  • 1
  • 15
  • 32
  • 1
    Note, INSERT IGNORE also ignores other errors such as partitioning allocation errors and does not only ignore key conflicts. – Gyrien Aug 04 '20 at 18:20