I am new to MySQL (have just been using SQL Server) and I am wondering how to create multiple rows easily!
I am looking to create about 300 rows, so the methods I have found online just don't seem practical enough..
When using SQL Server, you can just use a GO statement, and then enter a number afterwards and it will run the command that many times, such as : GO 50
Is there anything as simple as this on MySQL? I have read about using a loop statement, but I cannot find any info on it?
Any help will be really appreciated!
Thanks,
-Liam.
解决方案
Without using loop:
CREATE TABLE noderedtest(Password TEXT, Email TEXT);
INSERT INTO noderedtest (Password, Email) -- storing password in clear text
-- is very bad idea
WITH RECURSIVE cte AS
(
SELECT 1 AS i
UNION ALL
SELECT i+1
FROM cte
WHERE i < 300
)
SELECT 'Test', 'email@email.com'
FROM cte;
SELECT * FROM noderedtest;