Welcome Guest, Not a member yet? Register   Sign In
Database Foreign key Problem
#1

[eluser]rainfall[/eluser]

This problem occurred when i trying to insert data in tbl_add_designation table


Code:
Error Number: 1452

Cannot add or update a child row: a foreign key constraint fails (`db_erp_hr`.`tbl_add_designation`, CONSTRAINT `FK1_designation` FOREIGN KEY (`dept_id`) REFERENCES `tbl_add_department` (`dept_id`))

INSERT INTO `tbl_add_designation` (`desig_name`, `dept_name`) VALUES ('IT Officer', 'Admin ')

detp_id is the foreign key for department table .

How to solve it ??
#2

[eluser]CroNiX[/eluser]
You'd be better off googling that standard mysql error and learn about it. Hard to answer exactly why it happens for you without knowing your db schema. But if I had to guess the dept_id does not exist in your department table, so you can't use it in another table that has the fk constraint.




Theme © iAndrew 2016 - Forum software by © MyBB