🛠️ Scheduled Maintenance | We’ll be undergoing scheduled maintenance and upgrades between 00:00 PST Jan 26th until 00:00 PST Jan 28th. There may be brief interruption of services in that period. We apologize for the inconvenience.

The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Anybody can ask a question
Anybody can answer
The best answers are voted up and moderated by our team

SQL insert statement error

SQL insert statement error


In the exercise of the sql course under the insert statement lecture 1, I encountered an error stating MySQL error 1452 – Cannot add or update a  child row: a foreign key constraint fails. I ran the solution to the exercise provided by the course yet I still encountered same error message. Please how do solve this problem as I wish to be clear on what ever I am doing before moving on. Thank You.

MySQL error 1452 – Cannot add or update a child row: a foreign key constraint fails?

1 Answer

365 Team

Hi Mark!
Thanks for reaching out.
You may have missed adding record corresponding to employee 999903 in the ’employees’ table first. Please do that, since the ’employees’ and ‘salaries’ tables are interconnected.
Hope this helps.