1.通用方法:使用@变量
SELECT @row_number := @row_number + 1 AS row_number, a.dept_name FROM sys_department a,(SELECT @row_number:=0) b ORDER BY dept_name;
2.高版本即MySQL 8.0或MariaDB10.5开始支持的ROW_NUMBER()
函数
SELECT ROW_NUMBER() OVER (ORDER BY column_name) AS row_number, column_name FROM table_name;
标签:name,number,MySQL,序号,MariaDB,ORDER,SELECT,row From: https://www.cnblogs.com/dirgo/p/17684206.html