Databases| SQL| MySQL| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Mysql Looping 
 

Looping in Mysql is a simple loop construct,that enables the repeated execution of the statement list.

 

Mysql Looping

                         

Looping in Mysql is a simple loop construct,that enables the repeated execution of the statement list.This include one or more statements.Each statement is terminated by a semicolon(;). The statement inside a loop are repeated untill the loop is existed.The Leave statement is used to accomplished.

Understand with Example

The Tutorial illustrate an example from 'Mysql Looping'.To understand this example we create a procedure 'ABC' that include  BEGIN-END label consists of declare variable.The set keyword is used to set the value of variable 'a'.The loop runs within the block till the value of variable 'a' become 3.The Loop will be terminated once variable become more than 3.The loop is existed from the statement list.

 

 

 

Query to Create Procedure named ABC:

mysql> drop procedure if exists ABC;
    ->  CREATE PROCEDURE ABC()
    ->             BEGIN
    ->             DECLARE a INT Default 0 ;
    ->             simple_loop: LOOP
    ->               SET a=a+1;
    ->               select a;
    ->               IF a=3 THEN
    ->                  LEAVE simple_loop;
    ->               END IF;
    ->             END LOOP simple_loop;
    ->      ENDGG
Query OK, 0 rows affected, 1 warning (0.00 sec)
Query OK, 0 rows affected (0.06 sec)

Output :

mysql> call abc();
    -> GG
+------+
| a    |
+------+
|    1 |
+------+
1 row in set (0.02 sec)
+------+
| a    |
+------+
|    2 |
+------+
1 row in set (0.22 sec)
+------+
| a    |
+------+
|    3 |
+------+
1 row in set (0.42 sec)
Query OK, 0 rows affected (1.30 sec)

                         

» View all related tutorials
Related Tags: sql mysql c database file text data import backup load sed port int create tab tex loader example to base

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.