mysql-行号
作者:互联网
--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
标签:temp,tempid,行号,mysql,rownum,ORDER,SELECT 来源: https://www.cnblogs.com/tangtang-benben/p/16198238.html