Jump to content

[SOLVED] Create table


anon191

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.