Jump to content

Recommended Posts

I'm writing a 'create table' script, but it keeps being rejected by SQL and I'm not sure why, any ideas would be much appreciated!!

 

CREATE TABLE Order_Line
(Order_id INT(4) NOT NULL AUTO_INCREMENT,
username VARCHAR(15) NOT NULL,
print_ida VARCHAR(4) NOT NULL,
print_idb VARCHAR(4) NOT NULL,
print_idc VARCHAR(4) NOT NULL,
Constraint Pk_order Primary Key(Order_id),
INDEX ( username ),
Constraint FK_username FOREIGN KEY (username) REFERENCES Customer( username ) ON DELETE CASCADE)
INDEX ( print_ida ),
Constraint FK_pida FOREIGN KEY (print_ida) REFERENCES Prints( print_id ) ON DELETE CASCADE)
INDEX ( print_idb ),
Constraint FK_pidb FOREIGN KEY (print_idb) REFERENCES Prints( print_id ) ON DELETE CASCADE)
INDEX ( print_idc ),
Constraint FK_pidc FOREIGN KEY (print_idc) REFERENCES Prints( print_id ) ON DELETE CASCADE)
TYPE = INNODB;

 

And I get the error message:

#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 '( print_ida ),

Constraint FK_pida FOREIGN KEY (print_ida) REFERENCES Prints( pr' at line 10

 

Please help me!

Link to comment
https://forums.phpfreaks.com/topic/156822-solved-create-table/
Share on other sites

You counted wrong then. There are three more ) than (

 

CREATE TABLE Order_Line
(Order_id INT(4) NOT NULL AUTO_INCREMENT,
username VARCHAR(15) NOT NULL,
print_ida VARCHAR(4) NOT NULL,
print_idb VARCHAR(4) NOT NULL,
print_idc VARCHAR(4) NOT NULL,
Constraint Pk_order Primary Key(Order_id),
INDEX ( username ),
Constraint FK_username FOREIGN KEY (username) REFERENCES Customer( username ) ON DELETE CASCADE,
INDEX ( print_ida ),
Constraint FK_pida FOREIGN KEY (print_ida) REFERENCES Prints( print_id ) ON DELETE CASCADE,
INDEX ( print_idb ),
Constraint FK_pidb FOREIGN KEY (print_idb) REFERENCES Prints( print_id ) ON DELETE CASCADE,
INDEX ( print_idc ),
Constraint FK_pidc FOREIGN KEY (print_idc) REFERENCES Prints( print_id ) ON DELETE CASCADE)
TYPE = INNODB;

Link to comment
https://forums.phpfreaks.com/topic/156822-solved-create-table/#findComment-826584
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.