Mysql error 1452 - Cannot add or update a child row: a foreign key constraint fails

前端 未结 21 2324
生来不讨喜
生来不讨喜 2020-11-22 01:32

I\'m having a bit of a strange problem. I\'m trying to add a foreign key to one table that references another, but it is failing for some reason. With my limited knowledge o

21条回答
  •  遇见更好的自我
    2020-11-22 02:32

    This also happens when setting a foreign key to parent.id to child.column if the child.column has a value of 0 already and no parent.id value is 0

    You would need to ensure that each child.column is NULL or has value that exists in parent.id

    And now that I read the statement nos wrote, that's what he is validating.

提交回复
热议问题