INSERT IGNORE
Complete INSERT IGNORE reference: ignore insert errors and warnings, duplicate key error handling, invalid value coercion, and SHOW WARNINGS compatibility.
Ignoring Errors
Examples
CREATE TABLE t1 (x INT UNIQUE);
INSERT INTO t1 VALUES(1),(2);
INSERT INTO t1 VALUES(2),(3);
ERROR 1062 (23000): Duplicate entry '2' for key 'x'
SELECT * FROM t1;
+------+
| x |
+------+
| 1 |
| 2 |
+------+
INSERT IGNORE INTO t1 VALUES(2),(3);
Query OK, 1 row affected, 1 warning (0.04 sec)
SHOW WARNINGS;
+---------+------+---------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------+
| Warning | 1062 | Duplicate entry '2' for key 'x' |
+---------+------+---------------------------------+
SELECT * FROM t1;
+------+
| x |
+------+
| 1 |
| 2 |
| 3 |
+------+See Also
Last updated
Was this helpful?

