James Skidmore
James Skidmore

Reputation: 50338

Why does this MySQL statement throw a syntax error?

SQL statement:

INSERT INTO order (`ORDER_ID`,`SALE_CODE`,`CREATED_AT`,`UPDATED_AT`) VALUES ('2646253286','HPHS20','2009-07-11 12:07:40','2009-07-11 12:07:40')

Error:

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_ID`,`SALE_CODE`,`CREATED_AT`,`UPDATED_AT`) VALUES ('2646253286','H' at line 1 

Upvotes: 0

Views: 99

Answers (2)

banjollity
banjollity

Reputation: 4540

You have a table called order which is a reserved word in SQL. I'm not exactly sure how to get around it in MySQL, but in SQL Server it would be something like

insert into [order] ...

Upvotes: 5

moo
moo

Reputation: 7789

Fix backticks (`) around order to fix this.

Upvotes: 5

Related Questions