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/