How to sovle issue of foreign key constraints fail?

Zakir Bangash :
ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: 
a foreign key constraint fails 
(`shahzain`.`branch`, CONSTRAINT `branch_ibfk_1` FOREIGN KEY (`mgr_id`) REFERENCES `employee` (`emp_id`) ON DELETE SET NULL)

This is issue?

GMB :

The error message is quite clear.

You are trying to insert a row in branch whose mgr_id does not exists in column emp_id of table emp. You have a foreign key constraint that prohibits that.

Either add the missing employee in emp, or attach the branch to another manager, that exists in employee.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=346147&siteId=1