anon191 Posted May 4, 2009 Share Posted May 4, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/156822-solved-create-table/ Share on other sites More sharing options...
anon191 Posted May 5, 2009 Author Share Posted May 5, 2009 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/156822-solved-create-table/#findComment-826562 Share on other sites More sharing options...
Mchl Posted May 5, 2009 Share Posted May 5, 2009 Count your parentheses Quote Link to comment https://forums.phpfreaks.com/topic/156822-solved-create-table/#findComment-826571 Share on other sites More sharing options...
anon191 Posted May 5, 2009 Author Share Posted May 5, 2009 Yep, done that, but it all looks in order to me ??? I dont know where I'm going wrong Quote Link to comment https://forums.phpfreaks.com/topic/156822-solved-create-table/#findComment-826576 Share on other sites More sharing options...
Mchl Posted May 5, 2009 Share Posted May 5, 2009 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; Quote Link to comment https://forums.phpfreaks.com/topic/156822-solved-create-table/#findComment-826584 Share on other sites More sharing options...
anon191 Posted May 5, 2009 Author Share Posted May 5, 2009 Ah I didn't realise they had to balance like that! Thankyou so much for your help, all is working now Greatly appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/156822-solved-create-table/#findComment-826587 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.