ON DUPLICATE KEY do nothing

Sometimes you just don’t want to do anything if a key already exists in the DB.

mysql> INSERT INTO `table` SET id=5, name=`arthur` ON DUPLICATE KEY UPDATE 0+0;

Source

Tags:

2 Responses to “ON DUPLICATE KEY do nothing”

  1. Thanks, was looking for this.

  2. Or use:
    INSERT IGNORE INTO `table` SET id=5, name=`arthur`

Leave a Reply