Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
错误#1064 mysql_Mysql - Fatal编程技术网

错误#1064 mysql

错误#1064 mysql,mysql,Mysql,我有以下sql查询: SELECT * from data where key="test" 当我运行它时,phpmyadmin给我以下错误 #1064 - You have an error in your SQL syntax; check the manual that corresponds 到 在第1行的“key=”test“LIMIT 0,30”附近使用正确语法的MySQL服务器版本 键列的类型是varchar(150) 您不应该将列命名为任何列。或者至少在查询中使用反勾号(`

我有以下sql查询:

SELECT * from data where key="test"
当我运行它时,phpmyadmin给我以下错误

#1064 - You have an error in your SQL syntax; check the manual that corresponds 
到 在第1行的“key=”test“LIMIT 0,30”附近使用正确语法的MySQL服务器版本

键列的类型是varchar(150)


您不应该将列命名为任何列。或者至少在查询中使用反勾号(``)来转义它们。

在MySQL中键是保留字。因此,在列名周围加上反勾(`)字符。在MySQL中,单引号和双引号之间也没有区别

SELECT * from data where `key`='test';
SELECT * from data where `key`="test";

关键字是MySQL中的保留字,您需要用反勾号引用它

SELECT * from data where `key`="test"

关键字
是mySQL中的保留字。重命名该列或将其放在backticks中``它解决了问题,谢谢:)
SELECT * from data where `key`="test"