Error querying database. 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 use near 'LIMIT 10' at line 29
### The error may exist in com/mall/Mapper/UserNeedMapper.java (best guess)
### The error may involve com.mall.Mapper.UserNeedMapper.getUserProductNeedList-Inline
### The error occurred while setting parameters
### SQL: SELECT n.id AS n_id, n.user_id, n.product_id, n.text, n.update_time, u.id AS u_id, u.openid, u.unionid, u.nick_name, u.avatar_url, u.gender, u.city, u.register_time, p.id AS p_id, p.name, p.description, p.image, p.price, p.stock, p.categories, p.member_price, p.tag FROM `user_need` AS n JOIN `user` AS u ON u.id = n.user_id JOIN `product` AS p ON p.id = n.product_id; LIMIT ?
### 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 use near 'LIMIT 10' at line 29
这个保持错很明显是sql 错误
我们把sql 提出来在 Sql 工具中进行查询
@Select("SELECT \n" +
" n.id AS n_id,\n" +
" n.user_id, \n" +
" n.product_id, \n" +
" n.text, \n" +
" n.update_time,\n" +
" u.id AS u_id, \n" +
" u.openid, \n" +
" u.unionid,\n" +
" u.nick_name,\n" +
" u.avatar_url,\n" +
" u.gender,\n" +
" u.city,\n" +
" u.register_time,\n" +
" p.id AS p_id, \n" +
" p.name, \n" +
" p.description,\n" +
" p.image,\n" +
" p.price,\n" +
" p.stock,\n" +
" p.categories,\n" +
" p.member_price,\n" +
" p.tag\n" +
"FROM \n" +
" `user_need` AS n\n" +
"JOIN \n" +
" `user` AS u ON u.id = n.user_id\n" +
"JOIN \n" +
" `product` AS p ON p.id = n.product_id;")
IPage<UserProductNeedVo> getUserProductNeedList(Page<UserProductNeedVo> page);
@Autowired
UserNeedMapper userNeedMapper;
public IPage<UserProductNeedVo> getUserProductNeedPage(int current, int size) {
// 创建分页对象
Page<UserProductNeedVo> page = new Page<>(current, size);
// 调用分页查询
return userNeedMapper.getUserProductNeedList(page);
}
@RequestMapping("/getUserProductNeed")
public ResponseResult getUserProductNeed(@RequestParam int page,@RequestParam int limit) {
IPage<UserProductNeedVo> productNeedPage = userNeedService.getUserProductNeedPage(page, limit);
return ResponseResult.success(productNeedPage);
}
百度加gpt 一番后无果
直接说结论吧
因篇幅问题不能全部显示,请点此查看更多更全内容