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?
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.