mysql在查询时获取自增序号

SELECT  (@i:=@i+1),A.asset_code FROM (SELECT @i:=0) as i,leo_strategic_indicators  A  order by A.score DESC ;

将(select @i:0)作为一个派生表
在通过前面的@i:=@i+1进行计算 循环加一,即可得到自增序号

猜你喜欢

转载自blog.csdn.net/qq_37823979/article/details/107355215