--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
所有博客均为自己学习的笔记。如有错误敬请理解。