Mysql Repeat Function

MySQL: REPEAT Function

This tutorial explains how to use the MySQL REPEAT function with syntax and examples.


The MySQL REPEAT function repeats a string a specified number of times.


The syntax for the REPEAT function in MySQL is:

REPEAT( string, number )

Parameters or Arguments


The string to repeat.


The number of times to repeat the string.


  • If number is less than 1, the REPEAT function will return an empty string.

Applies To

The REPEAT function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23


Let's look at some MySQL REPEAT function examples and explore how to use the REPEAT function in MySQL.

For example:

mysql> SELECT REPEAT('A', 2);
Output: 'AA'

mysql> SELECT REPEAT('a', 5);
Output: 'aaaaa'

mysql> SELECT REPEAT('abc', 2);
Output: 'abcabc'

mysql> SELECT REPEAT(' ', 6);
Output: '      '

mysql> SELECT REPEAT(3, 2);
Output: '33'

mysql> SELECT REPEAT('abc', 0);
Output: ''