I am trying to delete a few records but am getting the following error:
Cannot delete or update a parent row: a foreign key constraint fails
The thing is, the foreign key constraint is failing for only 1 or 2 of my 100 records I wish to delete. I wish to write a query which deletes these 98-99 records, skipping the 1 or 2 which failed, which I can later manually inspect and delete/modify. Not stopping because of some single problematic record, but continuing with the others, ignoring that.
Is there a neat way to do this ?
DELETE IGNORE
doesn't achieve the goal. According to mysqlperformanceblog.com/2012/02/02/…, in 5.0, no rows are deleted in case of a FOREIGN KEY error, but in 5.1 and 5.5, rows up until the error occurs are deleted, and subsequent rows are left untouched. – Aboutface