Mysql syntax seems correct

我们两清 提交于 2019-12-29 09:17:08

问题


So... I received:

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 = '48f9f4a3f5e10c63804400f320f46e26'' at line 1

and so I reflected it back to myself, on the webpage and it reads:

SELECT * FROM email_confirm WHERE email = 'censored@gmail.com' AND key = '48f9f4a3f5e10c63804400f320f46e26'

I don't see the issue.

MySQL version is 5.1.65-cll

Answer: KEY is a reserved word in mysql. Need backticks !


回答1:


key is a MySQL keyword. Since it's also the name of your field, enclose it with the appropriate symbols:

SELECT * FROM `email_confirm` WHERE `email` = 'censored@gmail.com' AND `key` = '48f9f4a3f5e10c63804400f320f46e26';



回答2:


Key is a reserved word. Use backticks to escape it.

... `key` = '48f9...'



回答3:


I think key is a reserved word. Use `key` instead.



来源:https://stackoverflow.com/questions/13829809/mysql-syntax-seems-correct

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!