MySQL Forums
Forum List  »  Newbie

Re: issues with foreign key constraint ERROR 1005
Posted by: Zach Ellis
Date: November 03, 2023 09:43AM

Hello Tony

after looking at your code this might be your problem.

https://stackoverflow.com/questions/12994919/errno-121-duplicate-key-on-write-or-update

the constraint names might have to be different. look at the other table that uses the same column for the foreign key and see if its using the same name. So the error might be referring that a constraint already has that name.

ALTER TABLE `TCTSandpit`.`tbl_Emp_Expences`
ADD CONSTRAINT `Emp_ID` change it to 'fk_1_Emp_ID' so that why if there is multiple of it which you have you can just change the number
FOREIGN KEY (`Emp_ID`)
REFERENCES `TCTSandpit`.`tbl_Emp_Details` (`Emp_ID`)
ON DELETE CASCADE
ON UPDATE CASCADE;

Regards
Zach Ellis

Options: ReplyQuote


Subject
Written By
Posted
Re: issues with foreign key constraint ERROR 1005
November 03, 2023 09:43AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.