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

Created by RahulLinked to 45.9m issues across 126 teams

tl;dr

This error message indicates that you are trying to add a row to the Ordrelinje table that does not have a matching row (OrderID) in the Ordre table. To resolve this issue, you must first insert the row into the Ordre table.

To do this, you must specify the foreign key constraint in the child table (Ordrelinje). This will ensure that any INSERT or UPDATE operation that attempts to create a foreign key value in the child table will be rejected if there is no matching candidate key value in the parent table (Ordre).