Mysql / MariaDB Loop - Selbe Query 10 mal oder beliebig wiederholen

Wenn man eine Query 10 mal wiederholen möchte, kann man so was verwenden:

Query 1:

 DELIMITER $$

 DROP PROCEDURE IF EXISTS mysql_loop_repeat_myprocedure1$$

 CREATE PROCEDURE mysql_loop_repeat_myprocedure1()

 BEGIN

 DECLARE x INT;

        

 SET x = 1;

        

 REPEAT

 INSERT INTO `users` ( `username` ) VALUES ( concat('BenutzerName', '-', (FLOOR(RAND() * 401) + 800)) );



 SET  x = x + 1;

        UNTIL x  > 10

        END REPEAT;

 

 END$$

 DELIMITER ;

Query 2:

CALL mysql_loop_repeat_myprocedure1();

 

 

Neuen Kommentar schreiben

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Suche

Neueste Kommentare