Reputation: 869
when I try to insert in the database I get the following error:
DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`vym`.`vendedor`, CONSTRAINT `fk_vendedor_division` FOREIGN KEY (`codigo_empresa`, `codigo_division`) REFERENCES `division` (`codigo_empresa`, `codigo`)) at vendedores_aes_insert_85 line 53
I know I have a constraint but I don't know how to interpret the message. What is the constraint and why?
Upvotes: 0
Views: 414
Reputation: 34055
The constraint is the foreign key on table vym.vendedor
; columns codigo_empresa
, codigo_division
) are referencing table division
columns (codigo_empresa
, codigo
).
Upvotes: 1
Reputation: 190945
It looks like the division
column is violating it. I would check the definition of the `fk_vendedor_division
constraint.
Basically, the error is saying that you are trying to use a division in the vendedor
table that doesnt exist in the other one.
Upvotes: 1