Last answered:

03 Jul 2021

Posted on:

28 Jun 2021

1

Getting error while inserting new record

insert into titles  (                  emp_no,      title,      from_date  )  values  (                  999903,      'Senior Engineer',      '1997-10-01'  ) Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (`employees`.`titles`, CONSTRAINT `titles_ibfk_1` FOREIGN KEY (`emp_no`) REFERENCES `employees` (`emp_no`) ON DELETE CASCADE) 0.000 sec

2 answers ( 0 marked as helpful)
Posted on:

02 Jul 2021

0

Hello Mohammad,
I had the same error pop up, I hope someone is able to answer your question soon.
Were you able to solve it though?

Posted on:

03 Jul 2021

0

Hi Bibire,
Yes, I did by using the syntax mentioned below.
insert into titles (emp_no, title, from_date, to_date)
values ('99903', 'Senior Engineer', '1997-01-01', '9999-01-01');

Submit an answer