Jump to content

Could anyone tell me what is wrong with this create table code?


Recommended Posts

Hello,

 

Could anyone tell me what is wrong with this code? Thanks for any help!

 

The error I am getting is:

#1072 - Key column 'Login_id' doesn't exist in table

 

Server version: 5.1.41

I have created already the Login_detail table I am referencing, so that one can not be the problem. Or can be???

 

CREATE TABLE IF NOT EXISTS CUSTOMERS (
Customer_id int(4) not null auto_increment,
Customer_name varchar(80) not null default '',
Customer_address1 varchar(50) not null default '',
Customer_address2 varchar(50) not null default '',
Customer_town varchar(50) not null default '',
Customer_postcode varchar(9) not null default '',
Customer_county	varchar(30) not null default '',
Customer_country varchar(30) not null default '',
Customer_phoneno int(14) not null,
Customer_email varchar(50) not null default '',
key Customer_id (Customer_id),
PRIMARY KEY (Customer_id),
FOREIGN KEY (Login_id) references login_detail(Login_id) on update cascade on delete cascade
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Hi

 

The line:-

 

FOREIGN KEY (Login_id) references login_detail(Login_id) on update cascade on delete cascade

 

the bit in bold refers to a column on the table you are creating while the bit underlined refers to a column on another table.

 

The table you are creating doesn't have a column called Login_id though.

 

All the best

 

Keith

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.