Skip to content

IGNORE

INSERT IGNORE INTO employees (emp_no, birth_date, first_name, last_name, gender, hire_date)
VALUES ('9999', '1965-02-02', 'John', 'Doe', 'M', '2002-07-30');
Query OK, 0 rows affected (0.00 sec)

The INSERT IGNORE statement prevents an error from occurring and skipping the row that would cause the error when inserting data into a table. In the provided example, if ‘9999’ already exists in the ‘emp_no’ column in the ‘employees’ table, the database engine would omit this row and carry on processing any subsequent rows. The output displays ‘Query OK, 0 rows affected’ meaning no row was inserted due to the IGNORE clause.