I have been struggling with how to create a Foreign key on these 2 tables (anchors, properties). The tables already exist and have data in them.
This is my script to create the Foreign Key and below is the error.
ERROR
Thanks for your help!
This is my script to create the Foreign Key and below is the error.
Code:
ALTER TABLE `anchors` ADD CONSTRAINT `PROPERTYID_FK` FOREIGN KEY (`PROPERTYID`) REFERENCES `properties` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION;
Code:
[SQL] ALTER TABLE `anchors` ADD CONSTRAINT `PROPERTYID_FK` FOREIGN KEY (`PROPERTYID`) REFERENCES `properties` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION;
[Err] 1452 - Cannot add or update a child row: a foreign key constraint fails (`mysql_renaud`.<result 2 when explaining filename '#sql-b18_49'>, CONSTRAINT `PROPERTYID_FK` FOREIGN KEY (`PROPERTYID`) REFERENCES `properties` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION)