MYSQL Tutorial

MySQL REPEAT() function

REPEAT() function

MySQL REPEAT() repeats a string for a specified number of times. Both the string and the number of times that string to be repeated are supplied as arguments.

The function returns NULL either any of the arguments is NULL.


REPEAT(str, count)


Name Description
str A string which is to be repeated.
count An integer indicating how many times the string str is to be repeated.

Syntax Diagram:

MySQL REPEAT() Function - Syntax Diagram

MySQL Version: 5.6

Video Presentation

Example: MySQL REPEAT() function

The following MySQL statement repeats the string ‘**-‘ 15 times.


SELECT REPEAT('**-',15); 

Sample Output:

mysql> SELECT REPEAT('**-',15); 
| REPEAT('**-',15)                              |
| **-**-**-**-**-**-**-**-**-**-**-**-**-**-**- | 
1 row in set (0.03 sec)

All String Functions

MySQL String Functions, slide presentation

Many of our valued users post comments along with piece of code. Disqus may, false positively, consider those piece of code as Bad or Starnge syntax and send those comments to spam automatically. Even if that happens, we will make sure those useful comments are taken out of spam and approved. It may take a couple of days for that though, but any useful comment will be brought to public view for sure. We regret if that happend to any user. You may write us directly regarding this to - w3resource[at]yahoo[dot]com.