mysql error #1452 appearing when trying to add a constraint
- by user1701484
I am trying to alter a table so That I can add a foreign key constraint in mysql database:
ALTER TABLE `Question` ADD CONSTRAINT `FK_question` FOREIGN KEY (`QuestionId`)
REFERENCES `Image_Question` (`QuestionId`) ON DELETE CASCADE ;
Problem is that it is giving me this error:
1452 - Cannot add or update a child row: a foreign key constraint fails (mobile_app.
'#sql-4517_15241', CONSTRAINT FK_question FOREIGN KEY
(QuestionId) REFERENCES Image_Question (QuestionId) ON DELETE
CASCADE)
What does this error actually mean and what are the possible solutions I might have to undertake in order to fix this?