MySQL Forums
Forum List  »  Newbie

Repeat query MySQL
Posted by: Liam Broughton
Date: April 24, 2018 08:42AM

Hi all,

I am trying to set a repeat statement (I am very new to MySQL) to repeat an insert statement I have. (Sorry for my bad terminology)

What I am basically trying to do is to create around 300 rows of data (all with the same values) by repeating the same insert statement.

I used to use SQL Server but changed over to MySQL due to a lot of the tutorials online being MySQL based for what I am trying to achieve.

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?

Here is the code I am trying:

REPEAT
INSERT INTO mysqltest.noderedtest (Password, Email)
VALUES ("Test", "email@email.com")
UNTIL Room Number >= 300
END REPEAT;

If anyone can let me know where I am goign wrong here that will be mostly appreciated!

Thanks,

-Liam.

Options: ReplyQuote


Subject
Written By
Posted
Repeat query MySQL
April 24, 2018 08:42AM
April 24, 2018 10:21AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.