各位好,請教一下問題
我先建立food及drink table後再建立order table
但總會錯誤在"REFERENCES food(foodid),..."
請教,該如何解決
謝謝
1. order_table table
- id
- username
- foodid
- drinkid
Create Command:
mysql>
create table order_table(
id int not null auto_increment,
user_name varchar(26) not null,
foodid int(11) not null,
drinkid int(11) not null,
primary key(id),
FOREIGN KEY foodid REFERENCES food(foodid),
FOREIGN KEY drinkid REFERENCES drink(drinkid)
)ENGINE=innodb;
2. food table
- foodid
- name
Create Commnad
mysql>
create table food (
foodid int(11) not null auto_increment,
name varchar(26) not null,
primary key(foodid)
)ENGINE=innodb;
3. drink table
- drinkid
- name
Create Command
create table drink (
drinkid int(11) not null auto_increment,
name varchar(26) not null,
primary key(drinkid)
)ENGINE=innodb;
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.134.94.102
※ 編輯: wtuxxj 來自: 220.134.94.102 (03/04 09:05)