0

I have set up a table with a column called order. I made sure it is set as INT. I can't seem to get the results to list in order. I currently have 5 rows with numbers 1-5 in a random order in those rows. However, I can't get those rows to go in order. Maybe I am doing this completely wrong, as I am new to MySql. Here is my query

SELECT * FROM faq ORDER BY 'order'
4

5 回答 5

3

您应该使用反引号,而不是引号:

SELECT * FROM faq ORDER BY `order`
于 2013-06-27T19:23:15.410 回答
3

您需要在 mysql 中使用反引号,而不是引号。

SELECT * FROM faq ORDER BY `order`
于 2013-06-27T19:23:25.753 回答
2

你需要:

SELECT * FROM faq ORDER BY `order`

您在示例中使用单引号。MySQL 使用反引号来包装表名、字段名等。在这种情况下,您需要使用反引号,因为order它是 MySQL 中的保留字。

于 2013-06-27T19:23:11.080 回答
1

'order'像字符串一样引用,因此排序将由值order本身(字符串)而不是列完成。将它们改为反引号。

于 2013-06-27T19:23:19.227 回答
0

您应该使用 backtik 而不是引号:

SELECT * FROM faq ORDER BY `order`;

参考:http ://dev.mysql.com/doc/refman/5.0/en/identifiers.html

于 2013-06-28T06:26:53.267 回答