I am trying to add a foreign key to one of my tables. When I execute the following SQL Code:

ALTER TABLE `bpa`.`confinvitems` ADD CONSTRAINT `FK_confinvitems_1` FOREIGN KEY `FK_confinvitems_1` (`InvDetID`)
REFERENCES `confinvdet` (`ID`)
ON DELETE CASCADE;

I get the error:

MySQL Error Number 1452
Cannot add or update a child row: a foreign key constraint fails (`bpa/#sql-162c_1b`, CONSTRAINT `FK_confinvitems_1` FOREIGN KEY (`InvDetID`) REFERENCES `confinvdet` (`ID`) ON DELETE CASCADE)

I have checked, and all the indexes seem to be in place, the data types are exactly the same. There are no duplicate ID's in the ConfInvDet table. Any idea what this error means, and how to fix it?

Thanks,
Jesse

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to