I'm trying to link 2 tables together in the database I created. but I'm getting #1452 - Cannot add or update a child row error.
interestingly, it allows me to establish a fk-pk relationship when the table is empty, but I get an error when I pass data to the table with csv. when I first set up relationships and then try to import the data, I get the error adding this time.
what would be the reason?
SQL Query:
ALTER TABLE `kickstarter` ADD FOREIGN KEY (`country_num`) REFERENCES `kickstarter_countries`(`country_id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
MySQL Output:
1452 - Cannot add or update a child row: a foreign key constraint fails (
htimurat_data_analytics
.#sql-f8c5_6a687
, CONSTRAINT#sql-f8c5_6a687_ibfk_1
FOREIGN KEY (country_num
) REFERENCESkickstarter_countries
(country_id
))