mysql5.6生成排序欄位

自在现实發表於2024-05-24

SELECT
tt.id,
( @rowNum := @rowNum + 1 ) AS ranking
FROM
( select 5 as id union all select 4 as id union all select 3 as id union all select 2 as id union all select 1 as id
ORDER BY id
) tt
,( SELECT ( @rowNum := 0 ) ) as e

出處:https://www.cnblogs.com/suheng01/

相關文章