MySQL查询
SELECT option as value, name as text from jos_components where parent = 0 and enabled=1 order by name
我有一个表jos_components
,其字段名称为option
。我想在查询之上运行,但它给了我一个错误。
#1064 - 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 as value, name as text from jos_components where parent = 0 and enabled=1' at line 1
有什么问题?
答案 0 :(得分:3)
option
是MySQL reserved word。您必须在查询中使用反引号将其包围。试试这个:
SELECT `option` as value, name as text from jos_components where parent = 0 and enabled=1 order by name