Computer >> Computer tutorials >  >> Programming >> MySQL

How to replicate a string for a specified number of times in MySQL?


With the help of MySQL REPEAT() function, we can replicate a string for a specified number of times.

Syntax

REPEAT(Str, No.)

Here 

  • Str is the string which is to be replicated for a specified number of times.
  • No. is the numerical value which indicates that how many times the string would be repeated.

Example

mysql> Select REPEAT('#*',5);
+----------------+
| REPEAT('#*',5) |
+----------------+
| #*#*#*#*#*     |
+----------------+
1 row in set (0.00 sec)