Skip to content
Advertisement

ERROR 1452 (23000): cannot add or update a child row. [closed]

enter image description here

what could be the problem here?help me please 🙂 and please explain hehe thanks! 🙂

Advertisement

Answer

because you have set FOREIGN KEY constraint on your table category.

Insert into ads values (1, 'pd');        // successful
DELETE from ads                          // successful
INSERT INTO category VALUES (1,1,'a');   // failed!

the third query failed because value for adid which is 1 doesn’t exist anymore on table category. In other words, the value for adid on table category is depended on the values for ID on table ads.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement