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
  • 101,766
  • 154
  • 423
  • 727

1 Answers1

3

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,723
  • 1
  • 14
  • 32
  • 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