JorgeeFG
JorgeeFG

Reputation: 5981

Query giving error when using 'key' column

this query is giving me an error when I add the key column, any help?

username and product are composite primary key, just in case.

mysql> select * from sw_product_session where username='admin';
+----------+----------+------------+----------------------------+
| username | product  | expire     | key                        |
+----------+----------+------------+----------------------------+
| admin    | printbox | 1373550885 | 2ijm77cpnfc7miktasopkik2q2 |
+----------+----------+------------+----------------------------+
1 row in set (0.00 sec)

mysql> select * from sw_product_session where username='admin' AND product='printbox';
+----------+----------+------------+----------------------------+
| username | product  | expire     | key                        |
+----------+----------+------------+----------------------------+
| admin    | printbox | 1373550885 | 2ijm77cpnfc7miktasopkik2q2 |
+----------+----------+------------+----------------------------+
1 row in set (0.00 sec)

mysql> select * from sw_product_session where username='admin' AND product='printbox' AND key='2ijm77cpnfc7miktasopkik2q2';
ERROR 1064 (42000): 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='2ijm77cpnfc7miktasopkik2q2'' at line 1

Upvotes: 0

Views: 57

Answers (1)

tadman
tadman

Reputation: 211680

You need to remember that any reserved words need to be escaped:

AND `key`='...'

Upvotes: 8

Related Questions