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)

Swarali Sree
Swarali Sree

I love thought experiments.

Updated on: 10-Feb-2020

121 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements