码迷,mamicode.com
首页 > 数据库 > 详细

获取mysql行号最快最有效的方法

时间:2014-11-13 18:51:11      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   ar   os   sp   div   on   2014   

来源: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

  

 

获取mysql行号最快最有效的方法

标签:style   blog   http   ar   os   sp   div   on   2014   

原文地址:http://www.cnblogs.com/lucky110100/p/4095458.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!