1

I'm trying to do a really simple sort on a varchar column, and I get a syntax error. Tested both with PHP and phpmyadmin.

This is the query:

SELECT * FROM cards_available_properties ORDER BY option

this is the error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'option LIMIT 0, 30' at line 1

John Woo
  • 249,283
  • 65
  • 481
  • 481
Moshe Shaham
  • 14,666
  • 21
  • 68
  • 104

1 Answers1

5

OPTION is a reserved keyword. escape it with backtick.

SELECT * FROM cards_available_properties ORDER BY `option`
John Woo
  • 249,283
  • 65
  • 481
  • 481