Skip to content
Advertisement

mySQL – create table error 1064(42000): syntax error

I’m trying to create the table below but I get an error. I double checked and the data types are valid, and a table with this name doesn’t currently exist in the database. I even closed and re-opened my terminal in case this was a glitch. But still no luck. Any idea what’s wrong here?

create table order (order_no int, purch_amt decimal(6,2), order_date date, customer_id int, salesman_id int);

Error message I get: 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 (order_no int, purch_amt decimal(6,2), order_date date, customer_id int, s’ at line 1

Advertisement

Answer

order is SQL keyword. I would suggest calling the table orders. I would suggest:

create table orders (
    order_no int,
    purch_amt decimal(6,2),
    order_date date,
    customer_id int,
    salesperson_id int
);
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement