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'
Michael St Clair
  • 5,937
  • 10
  • 49
  • 75

5 Answers5

3

You should use the back-tick, not the quote:

SELECT * FROM faq ORDER BY `order`
Travesty3
  • 14,351
  • 6
  • 61
  • 98
Jehad Keriaki
  • 545
  • 5
  • 10
3

You need to use backticks in mysql, not quotes.

SELECT * FROM faq ORDER BY `order`
Robbert
  • 6,481
  • 5
  • 35
  • 61
2

You need:

SELECT * FROM faq ORDER BY `order`

You're using single-quotes in your example. MySQL uses backticks for wrapping table names, field names, etc. You need to use backticks in this case because order is a reserved word in MySQL.

WWW
  • 9,734
  • 1
  • 29
  • 33
1

You're quoting 'order' like a string, so the sorting will be done by the value order itself (a string) rather than by the column. Change them to backticks instead.

viraptor
  • 33,322
  • 10
  • 107
  • 191
0

You should use backtik not quotes:

SELECT * FROM faq ORDER BY `order`;

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

Sathish D
  • 4,854
  • 31
  • 44