---
slug: /repeat
---

# REPEAT

The `REPEAT` statement is used to execute a statement repeatedly.

The syntax of the `REPEAT` statement is as follows:

```sql
[begin_label:] REPEAT
    statement_list
UNTIL search_condition
END REPEAT [end_label]
```

The `statement_list` in the `REPEAT` statement is executed repeatedly until the `search_condition` expression evaluates to True. Therefore, the `REPEAT` statement will execute at least once. The `statement_list` consists of one or more statements, each ending with a semicolon (;). You can use `label` to mark the `REPEAT` statement.

Here is an example of a `REPEAT` statement:

```sql
DELIMITER //

CREATE PROCEDURE rep_proc(p1 INT)
       BEGIN
         SET @x = 0;
         REPEAT
           SET @x = @x + 1;
         UNTIL @x > p1 END REPEAT;
       END
       //
Query OK, 0 rows affected

CALL rep_proc(100)//
Query OK, 0 rows affected

SELECT @x//
+------+
| @x   |
+------+
| 101  |
+------+
1 row in set
```