• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Saturday, October 6, 2012

LOOPING IN MYSQL


Hi.. welcome to my blog.. You are on “We Are Knowledge”. The blog with to fill many IT knowledge.. IT knowledge from basic until hard. I was present many it knowledge for you, from desktop programming until web programming.


Sample of desktop programming is program language Pascal, cobol, c++ and other. And sample for web programming is Php, MySQL, javascript. I also present you about design graphic likely adobe photoshop. But bit tutorial about it.
Now.. I want giving you tutorial about “MySQL” again, but with different tutorial. 


Proeviously I was made tutorial about “condition In Mysql”. And for this article about “Looping  In Mysql”.. you will know ?? let’s do it now… have fun to read friends..


1. Looping

looping's purpose all the same with if's purpose, since core of both to sort statement until meets expected point it.


So looping at Mysql is condition to make a statement will perpetually happen until that statement as statement which is expected.


this is function of looping :

1. to print same process
2. to print same statement
3. to sort point


there is three repetitive form in Mysql, which is:

1. LOOP – AND LOOP

General form :

[ label : ] LOOP
            Statement
END LOOP [ label ];


2. REPEAT – UNTIL – END REPEAT

General form :

[ label : ] REPEAT
Statement
UNTIL expression
END REPEAT [ label ]


3. WHILE – END WHILE

General form :

[ label : ] WHILE expression DO
            Statements
END WHILE [ label ]


And this example looping, you can try it !!

Example 1 :

SET a = 1
V_loop : WHILE a <= 5 DO
            IF MOD (a, 2) = 0 THEN
                        SELECT CONCAT (a, “  Is round”);
            END IF
SET a = a + 1;
END WHILE v_loop;


To result :

0 is round
2 is round
4 is round


Ok.. just it..
I hope you likely..
See you laters

No comments:

Post a Comment