来源:http://blog.csdn.net/zht666/article/details/8854606
有个小问题是,要把这句提前(select @rownum := 0)t,否则第一次查询行号会为空。
示例:
select t1.* from (select @rownum := 0) t, ( select @rownum := @rownum + 1 as rownum, userid from t_user where login_date >= '2014-07-01' and login_date < '2014-09-01' limit 1000 )t1