开发者

How to get the value from MySQL from table field like 'Feildname-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


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';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜