0
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

1
  • 3
    a foreign key has to reference something.. Commented Aug 20, 2015 at 11:32

2 Answers 2

1

Add reference to foreign key by replacing

FOREIGN KEY(User_id)

with

foreign key(user_id) references referred_table(referred_col)
Sign up to request clarification or add additional context in comments.

Comments

0

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

2 Comments

You can also set the ON DELETE and ON UPDATE as per your requirement.
If my answer as helped you in any ways then you can accept my answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.