SQL query: Can't order by column called “order”?

后端 未结 7 1810
忘掉有多难
忘掉有多难 2021-01-14 03:27

I am pulling a column in an existing script into my template files, and everything is working great.

The only problem is, that this script has a column called

7条回答
  •  南方客
    南方客 (楼主)
    2021-01-14 04:24

    order is a keyword in SQL. So if you wish to use a keyword as a name, use backtick characters around it:

    SELECT * FROM categories WHERE hide = 0 ORDER BY `order`
    

    Try that :)

提交回复
热议问题