1

I have been looking at the below sql script for ages now and I can't see the problem! It's getting error 1064 - which could be anything...

CREATE TABLE order (order_no INTEGER NOT NULL AUTO_INCREMENT,
                vat_id INTEGER NOT NULL,
                order_status VARCHAR(30) NOT NULL,
                order_pick_date DATE,
                order_ship_from INTEGER NOT NULL,
                employee_id INTEGER NOT NULL,
                payment_id INTEGER,
                PRIMARY KEY (order_no))
        ENGINE = MYISAM;

3 Answers 3

1

Order is a reserved word in SQL, pick a different name for your table.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for that - it's so easy to look at these things for hours and miss the obvious!
1

The problem is that you are trying to create a table using a reserved name. If you change the table name to 'orders' then it will work.

Have a look at https://dev.mysql.com/doc/refman/5.5/en/reserved-words.html for the full list of reserved words.

Comments

1

As others have already pointed , the reserved word order is the issue .

However if you need to , you can still use it by enclosing with backticks / backquotes :

`order`

The corrected SQL statement ( which worked for me in MySQL 5.5.24 ) is :

CREATE TABLE
`order`
(
     order_no INTEGER NOT NULL AUTO_INCREMENT
    ,vat_id INTEGER NOT NULL
    ,order_status VARCHAR(30) NOT NULL
    ,order_pick_date DATE
    ,order_ship_from INTEGER NOT NULL
    ,employee_id INTEGER NOT NULL
    ,payment_id INTEGER
    ,PRIMARY KEY (order_no)
)
ENGINE = MYISAM;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.