Reputation: 1
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
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
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