ERROR 1452: Cannot add or update a child row: a foreign key constraint fails

MySQL supports foreign keys, which permit cross-referencing related data across tables, and foreign key constraints, which help keep the related data consistent.

A foreign key relationship involves a parent table that holds the initial column values, and a child table with column values that reference the parent column values. A foreign key constraint is defined on the child table.





Execute one of these lines before running your query, then you can run your query successfully. 🙂

1) For Session (recommended)


2) Globally


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *