I'm trying to insert a foreign key in my table A (in phpmyadmin):
ALTER TABLE A ADD FOREIGN KEY (id_B) REFERENCES B(id_B);
But I get the error:
1452 - Cannot add or update a child row: a foreign key constraint fails (database.<result 2 when explaining filename '#sql-edf_534aa1'>, CONSTRAINT #sql-edf_534aa1_ibfk_1 FOREIGN KEY (id_B) REFERENCES B (id_B))
Table A has id_A as primary key and Table B has id_B as primary key. Both table have innoDB as storage engine and the columns id_B in table A and id_B in table B have the identical types.
Whats in wrong and how can I fix it?