MySQL:Foreign key fails with error Error Code: 1452.

Today in MySQL, we add foreign keys to A table, the type is int, the name is not wrong, I temporarily want to add foreign keys to Table A table B, that is, the foreign keys in table A are associated with the primary key in table B.
NavigateSQL, however, always saves an operation with an error:
Foreign key fails with error error Code: 1452. Cannot add or update a child row: a Foreign key constraint fails: XXX.< result 2…

Go through Google and solve from StackOverflow!

The original B table I created temporarily had no data. When I added data to B table, I reported the same error again.

Originally, table A associated table B primary key field value, and table B value inconsistent, I manually changed the consistent “content consistent” can be!

StachOverflow:
http://stackoverflow.com/questions/7354032/foreign-key-fails-with-error-error-code-1452-cannot-add-or-update-a-child-row

Record here for accumulation!


Read More: