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

MySQLMySQLi Database

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)
raja
Published on 20-Feb-2018 10:43:55
Advertisements