天天看点

check the manual that corresponds to your MySQL server version for the right syntax to user near 'r

项目启动报错:

Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax;check the manual that corresponds  to your MySQL server version for the right syntax to user near 'rank,

这是之前写的一条 Mysql语句报的 SQL错误,但是仔细检查 SQL语句没有发现有什么异常问题。原来数据库表中有一个字段名为 rank,这和 SQL语句的关键字冲突了,导致出现了这个问题。

解决方法有两个:

1.在数据库表冲突字段前后加 `符号(Tab键上面那个键),就不会再报语法错误了;

2.修改数据库表中冲突字段名称,修改为和 SQL语句关键字不冲突的其他名称;

MySQL 8.0关键字和保留字

 https://dev.mysql.com/doc/refman/8.0/en/keywords.html#keywords-in-current-series

继续阅读