今天在写sql语句查询数据库时,范了一个容易被忽略的错误:
这是报错信息:
java.sql.SQLException: 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,typeId from goods where id = ‘7’’ at line 1 Query: select id,img,name,desc,typeId from goods where id = ? Parameters: [7]
原因:name 和 desc 是sql固有的关键字,使用的时候需要加反引号
解决办法:
成功解决!