Skip to content

Instantly share code, notes, and snippets.

@loomismilitia
Created December 4, 2017 10:46
Show Gist options
  • Save loomismilitia/450c0be3ffc8acc81e667b5fd690beba to your computer and use it in GitHub Desktop.
Save loomismilitia/450c0be3ffc8acc81e667b5fd690beba to your computer and use it in GitHub Desktop.
MySql Loop
drop procedure if exists doWhile;
SET @counter=5000;
CREATE PROCEDURE doWhile()
BEGIN
DECLARE i INT DEFAULT 0;
WHILE (i <= @counter) DO
INSERT INTO `test` (name) values ('loop sample');
SET i = i+1;
END WHILE;
END;
CALL doWhile();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment