--mysql没有rownum()函数,但是可以通过变量的方式来实现行号
①正序
SELECT
(@rownum :=@rownum + 1) AS rownum,
t.*
FROM
temp t,
(SELECT @rownum := 0) b
ORDER BY t.tempid ASC
②倒序
SELECT
(@rownum :=@rownum - 1) AS rownum,
t.*
FROM
temp t,
(SELECT @rownum := 8) b
ORDER BY t.tempid desc

posted on 2022-04-27 11:23  飞飞乐园  阅读(1921)  评论(0编辑  收藏  举报