[MySQL] 予約語でハマる - ERROR 1064 (42000): 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 'xxx' at line 1
MySQL でどう見ても大丈夫そうな SQL を実行したら文法エラーが発生しました。
mysql> SELECT * FROM addresses ORDER BY primary;
ERROR 1064 (42000): 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 'primary' at line 1
primary が予約語らしいので、シングルクォートで囲んで実行すれば大丈夫でした。
mysql> SELECT * FROM addresses ORDER BY 'primary';