tags:

views:

43

answers:

2

I have the following table:

table name: down
fields: id, key
and value in it is...
1, 1233

where id has INT 11 primary key and key is varchar

and my query is

SELECT * FROM down WHERE key='1233'

but it is not working please let me know what is actually the problem...

and giving me the following error

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 'key='5SD66R104'' at line

A: 

Put ` sign on table name and column name, like this:
SELECT * FROM down WHERE key='1233'

neverSayNo
+10  A: 

key is a reserved word in MySQL. If you reall want to use it (which I advise against) you have to quote it with ` like so:

SELECT * FROM down WHERE `key` = '123'
Jan Hančič
List of reserved words for MySQL: http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html
VolkerK