2013-07-11 11 views
0

이 쿼리는 key 열을 추가 할 때 오류가 발생합니까?MySQL 쿼리 이상한 오류

usernameproduct은 복합적인 기본 키입니다.

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 

답변

8

당신은 어떤 reserved words 필요가 도주 할 것을 기억해야합니다

AND `key`='...' 
+0

감사합니다! 그것이 문제였습니다. – JorgeeFG