--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