MySQL 字段 'option' 不起作用

标签 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 

有什么问题吗?

最佳答案

选项MySQL reserved word 。您必须在查询中用反引号将其括起来。试试这个:

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

关于MySQL 字段 'option' 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9029972/

相关文章:

mysql - 如何将另一个表中描述的期间的每个日期的行插入表中?

sql - Hibernate 如何最好地处理关联表/外键?

mysql - SQL查询性能对于MySQL来说太差了

html - CSS:用另一个 !important 覆盖 !important 不起作用?

jquery - 未捕获的类型错误 : undefined is not a function in Joomla! 模板

mysql - SQL 在表中划分子查询

mysql - 比较两个具有 4 个约束的 SQL 表并将匹配结果保存在新表中

SQL:Left Outer Join 可以根据列内的数据切换要连接的列

php - 如何使带有 PDT 的 Eclipse 与已注册的 Joomla namespace 别名一起工作?

php - 使用可变时区从 PHP 中的 UTC 转换