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
Add reference to foreign key by replacing
FOREIGN KEY(User_id)
with
foreign key(user_id) references referred_table(referred_col)
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.