mysql报1452错误求解决

问题遇到的现象和发生背景

mysql设置外键后向表中插入数据失败,提示1452 - Cannot add or update a child row: a foreign key constraint fails

用代码块功能插入代码,请勿粘贴截图

img

img

img

运行结果及报错内容

navicat报[Err] 1452 - Cannot add or update a child row: a foreign key constraint fails (stores.t_goods, CONSTRAINT fk_t_goods_reference_t_suppli FOREIGN KEY (Supp_code) REFERENCES t_suppliers (Supp_code))

我的解答思路和尝试过的方法

删除外键

我想要达到的结果

在外键有的情况下可以增加数据

你有多个外键,对应表里都要有数据才行啊
你要先在两个外表里加数据,才可以在t_goods里增加数据

https://blog.csdn.net/qq_37301964/article/details/124399661