2011-12-29 65 views
0

我試圖通過調整@s:= 1和@s < 1000來插入不同數量的行到我的表中,但它一次只插入一行。我究竟做錯了什麼?試圖插入行但SQL只插入1

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

回答

0

你可以試試這個?:

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