Reputation: 5018
What would be an equivalent of a break in a while loop for mysql?
WHILE (ctr < i)
DO ......
SET cnt = (SELECT COUNT(*) FROM temp_results WHERE result = "true");
IF cnt > 0 THEN
SELECT cnt;
BREAK;
END IF;
Thanks
Upvotes: 22
Views: 54702
Reputation: 5018
got it.
myloop: WHILE (ctr < i)
DO
…
SET cnt = (SELECT COUNT(*) FROM temp_results WHERE result = "true");
IF cnt > 0 THEN
SELECT cnt;
LEAVE myloop;
END IF;
END WHILE myloop;
Upvotes: 43
Reputation: 100667
You might be interested in a REPEAT
loop:
REPEAT
SET cnt = (SELECT COUNT(*) FROM temp_results WHERE result = "true");
UNTIL cnt > 0
END REPEAT;
Upvotes: 19