I have created some tables in for my database. I have been struggling with this error for a few hours now and I dont know how to resolve it.
INSERT INTO ark.playerfood VALUES ('1', '3') Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (
ark
.playerfood
, CONSTRAINTfk_PlayerFood_Player
FOREIGN KEY (playerID
) REFERENCESplayer
(playerID
))
[first one]
[second one]
[third one]
well , the error message is clear , you are violating the foreign key means that its one or combination of below issue:
the error message is complaining for the first case , but I pointed out the second point as it might show up if you don't have values in there.