前端分页后知道mysql数据ID在哪一页
例如coupon表,按id desc排序,表内有5条数据,每2条数据一页
输出就是
5
4
3
2
1
然后查询id=2的记录在第几页。
其中的MySQL操作代码
set @mycnt = 0; select * from (select (@mycnt:=@mycnt+1) as rownum,id from coupon order by id desc) as a where id=2;
例如coupon表,按id desc排序,表内有5条数据,每2条数据一页
输出就是
5
4
3
2
1
然后查询id=2的记录在第几页。
其中的MySQL操作代码
set @mycnt = 0; select * from (select (@mycnt:=@mycnt+1) as rownum,id from coupon order by id desc) as a where id=2;