开发者社区> 问答> 正文

Db的分页方法是如何执行的??报错

String sql = " active_comment  order by id desc";int startPage = 1,count=5;

Page<Record> dataPage = Db.paginate(startPage, count, "SET @num = 0; select @num :=@num+1 as numid,*", " from " + sql);

我想添加一个伪序列号,但是报错了:

com.jfinal.plugin.activerecord.ActiveRecordException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'select @num :=@num+1 as numid,*  from  active_comment ' at line 1

展开
收起
爱吃鱼的程序员 2020-06-10 10:44:36 457 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    这个sql是什么鬼?就是创建一个伪序号;目前找到其他方法来解决分页刷新问题了。

    2020-06-10 10:44:54
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
PolarDB NL2SQL: 帮助您写出准确、优化的SQL 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载