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

相關文章
相關標籤/搜索