Could someone please tell me why I am getting this error and what I should change!
mysql_exceptions.ProgrammingError: (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 'ORDER int,\n
FOREIGN KEY (ID) REFERENCES papers(ID),\n PRIMARY K' at line 4")
This is my statement:
""" CREATE TABLE Authors (
ID int NOT NULL,
AUTHOR varchar(255),
ORDER int,
FOREIGN KEY (ID) REFERENCES papers(ID),
PRIMARY KEY (ID, ORDER)
) """
Thank you I am new to sql and simply cannot spot where I have gone wrong!
"ORDER" is a reserved word and cannot be used as a field name...
Select * from Author order by order;
https://dev.mysql.com/doc/refman/5.5/en/keywords.html
If you absolutely want to use order as a field name, you must quote it, but it is better to avoid it, since you also would need to quote it in any sql sentence refering it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With