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
  • 258,903
  • 69
  • 498
  • 492
Moshe Shaham
  • 15,448
  • 22
  • 74
  • 114

1 Answers1

5

OPTION is a reserved keyword. escape it with backtick.

SELECT * FROM cards_available_properties ORDER BY `option`
John Woo
  • 258,903
  • 69
  • 498
  • 492