2

MySqlでリレーショナルデータベースを作成しようとしていますが、エラーが発生し、クエリの何が問題になっているのか本当にわかりません。

以下はgetです:

Error Code : 1072
Key column 'user_id' doesn't exist in table
(0 ms taken)

これが私の質問です:

CREATE TABLE tish_user(
user_id int(11) NOT NULL Auto_increment,
username varchar(30) NOT NULL,
Password varchar(41) NOT NULL,
Previllage VARCHAR(20) NOT NULL,
date_created datetime,
primary key (user_id )
)ENGINE=InnoDB;

CREATE TABLE tish_images(
image_id int(11) not null auto_increment,
image_name varchar(100) not null,
image_profile numeric(1) default 0,
FOREIGN KEY(user_id)REFERENCES tish_user(user_id)on update cascade,
primary key (image_id)
)ENGINE=InnoDB;


CREATE TABLE tish_clientinfor(
client_id int(11) not null auto_increment,
title  varchar(11) not null,
firstname varchar(30) not null,
lastname  varchar(30) not null,
client_code  varchar(30) not null,
date_registered  timestamp Default CURRENT_TIMESTAMP,
FOREIGN KEY(user_id)REFERENCES tish_user(user_id)on update cascade,
primary key (client_id)
)ENGINE=InnoDB;
4

1 に答える 1

2

で参照されているuser_id列がありません。おそらく1つ追加するつもりでしたか?tish_clientinforFOREIGN KEY(user_id)...

CREATE TABLE tish_clientinfor(
client_id int(11) not null auto_increment,
title  varchar(11) not null,
firstname varchar(30) not null,
lastname  varchar(30) not null,
client_code  varchar(30) not null,
date_registered  timestamp Default CURRENT_TIMESTAMP,
user_id int(11) not null, --this was the missing column
FOREIGN KEY(user_id)REFERENCES tish_user(user_id)on update cascade,
primary key (client_id)
)ENGINE=InnoDB;

同じことがテーブルにも当てはまりますtish_images

于 2013-01-26T13:01:51.670 に答える