总是得到外键错误

时间:2014-07-28 05:04:25

标签: mysql database foreign-keys

每当我设置外键时,我都会收到以下错误,我不知道为什么。有人可以帮我搞清楚吗?

Error
SQL query: ALTER TABLE  `vl_discount` ADD CONSTRAINT  `vl_product_ibfk1` FOREIGN KEY (  `discountedProduct` )
REFERENCES  `base`.`vl_product` (`autokey`) ON DELETE CASCADE ON UPDATE CASCADE ;
MySQL said: Documentation
#1452 - Cannot add or update a child row: a foreign key constraint fails
(`base`.`#sql41d_172`, CONSTRAINT `vl_product_ibfk1` FOREIGN KEY (`discountedProduct`)
REFERENCES `vl_product` (`autokey`) ON DELETE CASCADE ON UPDATE CASCADE) 

0 个答案:

没有答案