Reputation:
I have two tables and i have made foreign key relationship between them but i have set the foregin key nullable in the table but when i insert with foreign key column null, it gives me error:
Cannot add or update child row Foreign key contrain fails:
Here is the table screen in which i made foreign key:
I have made cliq_dependent_id column nullable but it has relation org_emp_dependents table id column
Upvotes: 0
Views: 835
Reputation: 62488
you must be inserting a value in the table that does not have reference key in the parent table.
For Example,
you are inserting 5 in the foreign key column, but if you check in the parent table rows, there will be no row with the id 5.
The second chance can be that you are inserting 0 instead of null.
Check these two things, i hope so it will get you out of the issue.
Upvotes: 1