这是我尝试连接两个表的 alter 语句:
ALTER TABLE my_contacts
CHANGE `profession` `profession_id` INT NOT NULL,
ADD CONSTRAINT professions_profession_id_fk
FOREIGN KEY (profession_id) REFERENCES professions (profession_id)
我有以下错误:
#1452 - Cannot add or update a child row: a foreign key constraint fails (`contacts`.<result 2 when explaining filename '#sql-1ca_73'>, CONSTRAINT `professions_profession_id_fk` FOREIGN KEY (`profession_id`) REFERENCES `professions` (`profession_id`))
谁能指导我这是什么?我实际上正在学习如何自己编写 sql,因为我一直在使用工具。