SELECT
`table`.*, (@rownum := @rownum + 1) AS ROWNUM
FROM
`table` inner join
(SELECT @rownum := 0) r
WHERE
1
ORDER BY
`table`.id;
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