Search code examples
mysqlmysql-error-1064

Mysql error code creating table


create table Order (ord_no int, purch_amt int check(purch_amt < 50), customer_id varchar(30), salesman_id varchar(30), Primary Key (ord_no));

ERROR 1064 (42000): 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 (ord_no int, purch_amt int check(purch_amt < 50), customer_id varchar(30),' at line 1


Solution

  • order is a reserved word in MySQL. Use some other name.

    See this related post: Syntax error due to using a reserved word as a table or column name in MySQL

    I think you can use back-ticks to quote your table name, but I think that is not a great idea.