mysql中使用行号

SELECT
`table`.*, (@rownum := @rownum + 1) AS ROWNUM
FROM
`table` inner join
(SELECT @rownum := 0) r
WHERE
1
ORDER BY
`table`.id;

原文地址:https://www.cnblogs.com/firstForEver/p/4447076.html