一 、自定义变量 SELECT (@n:=@n+1) AS num FROM article; 二、使用ROW_NUMBER() 函数(用时较短) SELECT ROW_NUMBER() over(order by title DESC