2012-01-27 86 views
2

MySQL查詢是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 

什麼問題?

回答

3

optionMySQL reserved word。您必須在查詢中用反引號包圍它。試試這個:

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

Thanks Asaph it work – 2012-01-27 07:08:49