单表
从0开始
SELECT
(@i := @i + 1) AS id
FROM
sys_region n1,
(SELECT @i := - 1) AS it
LIMIT 1000
从1开始
SELECT
(@i := @i + 1) AS id
FROM
sys_region n1,
(SELECT @i := 0) AS it
LIMIT 1000
多表
从0开始
SELECT
(@i := @i + 1) AS id
FROM
sys_region n1
CROSS JOIN sys_region AS n10
CROSS JOIN sys_region AS n100,
(SELECT @i := - 1) AS it
LIMIT 1000
从1开始
SELECT
(@i := @i + 1) AS id
FROM
sys_region n1
CROSS JOIN sys_region AS n10
CROSS JOIN sys_region AS n100,
(SELECT @i := 0) AS it
LIMIT 1000