mysql obtains self-increasing serial number when querying

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

Take (select @i:0) as a derived table
and add one to the calculation loop through the previous @i:=@i+1 to get the self-increasing serial number

Guess you like

Origin blog.csdn.net/qq_37823979/article/details/107355215