mysql 查询结果前面加上序号

select @x:=ifnull(@x,0)+1 as rownum,table.* from tablephp

ps: @x 变量是 connection 级的,再次查询的时候须要初始化。通常来讲PHP等B/S应用没有这个问题。但C/S若是connection一只保持则要考虑 set @x=0 M()->execute('set @x=0;'); //thinkphpthinkphp

http://blog.csdn.net/yibing548/article/details/45505281.net

相关文章
相关标签/搜索