-2

I am facing the error while executing insert or update operation in mysql. I have already define the relation between two tables still it throws error Error Code: 1452. Cannot add or update a child row:

a foreign key constraint fails ('test'.'system_review', CONSTRAINT 'system_review_ibfk_1' FOREIGN KEY ('SYS_USER_ID') REFERENCES 'user_details' ('USER_ID'))



   
Bhatt Akshay
  • 159
  • 1
  • 14
  • 1
    Have you tried searching on this site? http://stackoverflow.com/questions/1253459/mysql-error-1452-cannot-add-or-update-a-child-row-a-foreign-key-constraint-fa http://stackoverflow.com/questions/21659691/error-1452-cannot-add-or-update-a-child-row-a-foreign-key-constraint-fails http://stackoverflow.com/questions/5256703/sql-error-1452-cannot-add-or-update-a-child-row-a-foreign-key-constraint-fail – Danielson Jun 24 '15 at 12:05
  • Please show your SQL statement. That error could be caused by a number of problems, but my best guess is that you are trying to add a row which references a foreign key that does not exist. – Alex Jun 24 '15 at 12:05
  • Yes a foreign key constraint fails (test.system_review, CONSTRAINT system_review_ibfk_1 FOREIGN KEY (SYS_USER_ID) REFERENCES user_details (USER_ID)) //Help me to solve this error – Bhatt Akshay Jun 24 '15 at 12:06
  • It show me the error above sentence. – Bhatt Akshay Jun 24 '15 at 12:07
  • hey, just a friendly advice : after reading a few of your questions i came to the conclusion that it may be best for you to stick to programming basics for now ... nobody achieves world domination within a few days, you gotta start with the basics - meaning : no databases (at all), no other language than .... say, PHP or something, no complex code. Start with hello-world websites and work your way up from there. Forget about SQL and foreign key constraints for now, databases can be very complex beasts ... you gotta understand algorithms first. – specializt Jan 19 '16 at 05:17

1 Answers1

1

Possibly you have set Relationship between your two tables. And you are trying to update base record id, which is used by your child table.

Chintan7027
  • 7,115
  • 8
  • 36
  • 50