How can I make a table in MySQL called “order”?

后端 未结 3 1980
囚心锁ツ
囚心锁ツ 2020-12-01 23:36

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\".

<
相关标签:
3条回答
  • 2020-12-02 00:18

    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.

    0 讨论(0)
  • 2020-12-02 00:22

    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 :-)

    0 讨论(0)
  • 2020-12-02 00:35

    can you use something like?

    select * from `order`
    
    0 讨论(0)
提交回复
热议问题