tags:

views:

11

answers:

1

Hai I am having the table USERS with the fields like

USERACCNO
FIELD-1
FIELD-2
.
.
.
.
.
.
FIELD-10

Now I want to get the Value from field-2 .SO I wrote a query like this
SELECT FEILD-2 FROM USERS WHERE USERACCNO='1'
But It returns error.
So I wrote a query Like this SELECT 'FEILD-2' FROM USERS WHERE USERACCNO='1'
Here I got the result 'FEILD-2' instead of field-2 value.How can I get the result for field-2 value?What's the wrong with my query or table structure?Thanks in advance.

Updated: FEILD-2 to FIELD-2
FEILD-10 to FIELD-10

+3  A: 

You need to use backticks in MySQL for identifiers that contain special characters (such as the dash sign):

SELECT `FIELD-2` FROM users WHERE useraccno = '1';
Daniel Vassallo