尝试插入行但SQL只插入1

时间:2011-12-29 16:08:22

标签: mysql

我试图通过调整@s:= 1和@ s< 1000来向表中插入不同数量的行,但它一次只插入一行。我做错了什么?

INSERT INTO
    rent
    (
    id
    )
select @s:=@s+1 as seq
FROM (SELECT @s:=1) AS baseview, rent
WHERE @s<1000
ORDER by @s ASC;

1 个答案:

答案 0 :(得分:0)

你能试试吗?:

INSERT INTO
    rent
    (
    id
    )
SELECT seq FROM (
    select @s:=@s+1 as seq
    FROM (SELECT @s:=1) AS baseview, rent
    WHERE @s<1000
    ORDER by @s ASC
) seqSource;