MySQL字段'选项'不起作用

时间:2012-01-27 07:01:52

标签: mysql sql joomla

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 

有什么问题?

1 个答案:

答案 0 :(得分:3)

optionMySQL reserved word。您必须在查询中使用反引号将其包围。试试这个:

SELECT `option` as value, name as text from jos_components where parent  = 0 and enabled=1 order by name