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,064
  • 7
  • 51
  • 70

5 Answers5

3

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

SELECT * FROM faq ORDER BY `order`
Travesty3
  • 14,608
  • 6
  • 56
  • 96
Jehad Keriaki
  • 545
  • 5
  • 9
3

You need to use backticks in mysql, not quotes.

SELECT * FROM faq ORDER BY `order`
Robbert
  • 6,436
  • 5
  • 33
  • 60
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,334
  • 1
  • 27
  • 32
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
  • 32,414
  • 8
  • 104
  • 182
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,730
  • 28
  • 44