I have this statement:
INSERT INTO `alias`( `alias`, `ref_links_id`) VALUES ("3334",4)
And I get this error:
Cannot add or update a child row: a foreign key constraint fails
(`bestr_main`.`alias`, CONSTRAINT `alias_ibfk_1` FOREIGN KEY (`ref_links_id`)
REFERENCES `links` (`link_id`) ON DELETE CASCADE ON UPDATE CASCADE)
The alias table is connected to link table with a foreign key.
Why do I get this error when inserting a record?
I see now.. I tried to change the link between the keys to another table and I get this:
1452 - Cannot add or update a child row: a foreign key constraint fails
(`bestr_main`.<result 2 when explaining filename '#sql-73c_38e0'>, CONSTRAINT
`#sql-73c_38e0_ibfk_1` FOREIGN KEY (`ref_links_id`) REFERENCES `refs` (`ref_id`)
ON DELETE CASCADE ON UPDATE C)
What does that say?
Read the error
Means
and no child exist without parent. so first check parent table for the value which you are inserting into child table