MySQL - Error Code 1215, cannot add foreign key constraint

前端 未结 6 967
孤城傲影
孤城傲影 2020-12-11 18:04

i got these two succesfull queries:

create table Donors (
    donor_id int not null auto_increment primary key,
    gender varchar(1) not null,
    date_of_b         


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-12-11 19:08

    In MySql, a foreign key reference needs to reference to an index (including primary key), where the first part of the index matches the foreign key field. If you create an an index on condition_code or change the primary key st that condition_code is first you should be able to create the index.

提交回复
热议问题