Created
July 3, 2020 16:51
-
-
Save mikelemus27/c4baa39b69b55380f26d1f43a2e1d870 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select version() as 'mysql version'; | |
| #delimiter \\: | |
| drop procedure if exists p1; | |
| create procedure p1() | |
| begin | |
| declare ctr int default 0; | |
| declare i int default 10; | |
| myloop: WHILE (ctr < i) DO | |
| #SET cnt = (SELECT COUNT(*) FROM temp_results WHERE result = "true"); | |
| #select @ctr := ctr + 1;#only works for @variables( variales globales) | |
| #set ctr=@ctr;#passing value from global to local | |
| set ctr = ctr + 1;#using only local variables | |
| SELECT ctr; | |
| IF ctr > 5 THEN | |
| SELECT concat("last value of ctr: ",ctr) as LVCTR; | |
| LEAVE myloop; | |
| END IF; | |
| END WHILE myloop; | |
| end \\ | |
| call p1(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment