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 )
The string to repeat.
The number of times to repeat the string.
The REPEAT function can be used in the following versions of MySQL:
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: ''