"HProblem with the fk and pk which are in the same table and related."
So, i want to insert in table 'employee' values but the program show me error:
Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (ikbo_6
.employee
, CONSTRAINT employee_ibfk_1
FOREIGN KEY (manager_id
) REFERENCES employee
(employee_id
)).
insert into employee values
(1,'Mccain', 'Jhonny','D',1001,101,'2008-05-12',2000.90,100.45,801);
I tried first to add the data to pk_key and only then to the other columns, but this did not work.
insert into employee (last_name,first_name,middle_initial,manager_id,job_id,hire_date, salary, commission, department_id) values
('Mccain', 'Jhonny','D',1001,101,'2008-05-12',2000.90,100.45,801);
what am I doing wrong?
The struture employee_id int(6) not null auto_increment primary key,manager_id int(6)
and foreign key (manager_id) references Employee (employee_id)