How can I make a table in MySQL called "order"?
When I make a MySQL table order
, it is created successfully but, when I execute any query against it, it says "error 1064 , syntax error"
.
When I change the name to orders
, it works fine.
But I don't want to change the name. How can I execute our query against the order
table?
can you use something like?
select * from `order`
The word order
is actually an SQL keyword. You would have the same problem if you tried to use a table called group
or select
. You can fix it is MySQL by using quotes around it, along the lines of:
select f1, f2 from `order` where blah blah blah ...
However, unless your table will only ever hold a single order (in which case it won't do so for long since the underlying business will soon be bankrupt), you should probably call your table orders
.
That solves both your problems, the one you found and the one you didn't :-)
I got here because I was searching for similar solution for SQL CE. There using
order
'order'
"order"
doesn't work.
What worked was:
[order]
Maybe it'll help someone else also.