【已解决】You have an error in your SQL syntax
•
数据库
报错讯息
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 use near ‘desc,target_url,sort,status,create_by,modify_by,created,last_update_time FROM s’ at line 1
原因

我在实体类中使用 desc 作为字段名,而 desc 正好是 MySQL 中的关键字之一(用于排序)。
解决方法
使用 @TableField(value = “`desc`”) 这样的注解来明确告知 MyBatisPlus 在生成 SQL 查询语句时将该字段名使用反引号包裹起来,确保数据库正确识别它作为字段名而不是关键字。
@TableField(value = "`desc`") @ApiModelProperty(value="描述") private String desc;
本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://www.net2asp.com/ff8f078601.html
