[MySQL] Getting stuck with reserved words - 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
Tadashi Shigeoka · Sun, January 20, 2013
In MySQL, when I executed SQL that looked absolutely fine, a syntax error occurred.
ERROR 1064 (42000): You have an error in your SQL syntax;
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 is a reserved word
Since primary is apparently a reserved word, it was fine when I surrounded it with single quotes and executed it.
mysql> SELECT * FROM addresses ORDER BY 'primary';
参考情報
That’s all from the Gemba.