MYSQL テーブルのカラムにcolumnとか特殊文字・キーワードを含む場合
▼参照
http://dev.mysql.com/doc/refman/4.1/ja/legal-names.html
たとえば、以下のようなテーブル構造の場合
キーワードcolumnが入っているため、columnをselectしようとすると
参照があいまいになり、
+------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | type | varchar(255) | NO | MUL | NULL | | | column | varchar(255) | NO | | NULL | | select column from testtable 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
エラーをはく。
なので、testtableのcolumnを参照したい場合は、testtable.columnで参照を
明確にしてあげる必要がある。
select testtable.column from testtable