Answers for "mysql foreach loop"

SQL
0

mysql loop

-- MySQL LOOP, ITERATE, LEAVE, loop label
CREATE PROCEDURE LoopDemo()
BEGIN
	DECLARE x  INT;
	DECLARE str  VARCHAR(255);
	SET x = 1;
	SET str =  '';
	loop_label:  LOOP
		IF  x > 10 THEN 
			LEAVE  loop_label;
		END  IF;
		SET  x = x + 1;
		IF  (x mod 2) THEN
			ITERATE  loop_label;
		ELSE
			SET  str = CONCAT(str,x,',');
		END  IF;
	END LOOP;
	SELECT str;
END$$
Posted by: Guest on March-21-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language