gpt4 book ai didi

MySQL : Cannot add or update a child row: a foreign key constraint fails

转载 作者:行者123 更新时间:2023-11-30 22:20:46 27 4
gpt4 key购买 nike

我得到了错误:

Cannot add or update a child row: a foreign key constraint fails

这是我的插入查询:

INSERT INTO `swat` (`Category`, `Importance_JK`, `MaxStrength`, `Person_id`, `SWAT_id`, `Strength`, `cost`, `date_Complete`, `due_Date`, `storage_id`, `updated`, `user_FK`) 
VALUES ('1','2','we1','546','46','we','500','2016-04-19','2016-04-18','','2016-04-18','37')

如果我在 SQL 中打印此查询,则会发生此 MySql 错误:

#1452 - Cannot add or update a child row: a foreign key constraint fails (`sidemoin_crucialstuff`.`swat`, CONSTRAINT `swat_ibfk_3` FOREIGN KEY (`Person_id`) REFERENCES `key_people` (`Key_Person_ID`))

有什么帮助吗?

最佳答案

你得到这个错误是因为你的外键值没有被插入。所以你可以做一件事请在数据库中的 FK 列指定空值,然后尝试运行查询并检查

关于MySQL : Cannot add or update a child row: a foreign key constraint fails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36686545/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com