Search code examples
mysqlmysql-error-1064

mysql ERROR 1064 (42000): You have an error in your SQL syntax; check the manual


CREATE TABLE ORDER( Order_id INT PRIMARY KEY AUTO_INCREMENT, 
 Total_price FLOAT  NOT NULL, 
 Item_Serial_number INT NOT NULL, 
 Num_of_items INT NOT NULL, 
 Cust_username VARCHAR(25) NOT NULL, 
 Date_placed DATE NOT NULL, 
 Date_arrived DATE, 
 Cust_cart INT NOT NULL,
FOREIGN KEY(Cust_cart) REFERENCES CART(Cart_id),
FOREIGN KEY(Item_Serial_number) REFERENCES ITEM(Serial_number),
FOREIGN KEY(Cust_username) REFERENCES USER(Username));

Solution

  • As mentioned in comments, you should try CREATE TABLE "ORDER" as order is a term with meaning in SQL and needs to be quoted if you want to use it as a name. Better yet, don't use a reserved word as your table name (as this is confusing to other users) and call it something along the lines of PRODUCT_ORDERS