例如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;