Tarun Baraiya
Tarun Baraiya

Reputation: 504

MySQL field 'option' is not working

MySQL query is

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

I have a table jos_components which have field name option. I want to run above query but it gives me an error.

#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 

What's the problem?

Upvotes: 2

Views: 1433

Answers (1)

Asaph
Asaph

Reputation: 162801

option is a MySQL reserved word. You'll have to surround it with backticks in your query. Try this:

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

Upvotes: 3

Related Questions