MySQL 1064: You have an error in your SQL syntax

SQL 语法不被解析器接受的通用错误,错误位置通常在报错提示的 "near" 附近。

现象

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 'ORDER date LIMIT 10' at line 1

原因

解决

-- 保留字加反引号
SELECT id, `order` FROM t WHERE `group` = 1;

-- 字符串用单引号
INSERT INTO t(name) VALUES ('bug.icu');

-- 用 EXPLAIN / 客户端格式化定位 near 处
SHOW WARNINGS;

预防

← 返回报错速查库