mysql - Why do this error appear "#1215 - Cannot add foreign key constraint "? -


create table postcodes (     postcode_id int not null,     location varchar(50),     primary key (postcode_id) );  create table countries (     country_id int not null auto_increment,     country_name varchar(50),     primary key (country_id) );  create table suppliers (     supplier_id int not null auto_increment primary key,     supplier_name varchar(50),      supplier_forename varchar(50),     supplier_phonenumber varchar(20),     supplier_address varchar(50),      supplier_postcode int,     supplier_country int,     foreign key (supplier_postcode) references postcode(postcode_id),      foreign key (supplier_country) references countries(country_id) ) ; 

typo:

create table postcodes (                      ^----plural      foreign key (supplier_postcode) references postcode(postcode_id),                                                         ^----no s, singular 

you're trying reference table doesn't exist.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -