Joice Infentia
Joice Infentia

Reputation: 1

mysql error #1064 while creating table

CREATE TABLE Exhibitor_Info
(Ex_id int AUTO_INCREMENT,User_id int,Category varchar(150),Description varchar(400), PRIMARY KEY(Ex_id),FOREIGN KEY(User_id));

while executing this sql I got the following error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2

Can anyone help me to fix the problem

thanks

Upvotes: 0

Views: 104

Answers (2)

Sagar Panda
Sagar Panda

Reputation: 561

You have to add the reference to a foreign key

CREATE TABLE Exhibitor_Info (Ex_id int AUTO_INCREMENT,User_id int,Category varchar(150),Description varchar(400), PRIMARY KEY(Ex_id),FOREIGN KEY(User_id) REFERENCES referred_parent_table(referred_col) ON DELETE CASCADE);

You can have a good example here

Upvotes: 0

Aman Kaur
Aman Kaur

Reputation: 321

Add reference to foreign key by replacing

FOREIGN KEY(User_id)

with

foreign key(user_id) references referred_table(referred_col)

Upvotes: 1

Related Questions