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
Use ignore:
DELETE IGNORE ...
http://dev.mysql.com/doc/refman/5.0/en/delete.html
You have to LEFT JOIN the referencing table and add a condition saying that the row is missing in that table.
LEFT JOIN
For example:
DELETE a FROM a LEFT JOIN b ON b.a_id = a.id WHERE b.a_id IS NULL;