REPEAT(str,count)
If you want to repeat a string str at given times then you can use the REPEAT mysql function. REPEAT function returns a string consisting of the string str repeated count times. It returns an empty string if count is less than 1 and returns NULL if str or count are NULL.
Here are some example which will explain you this function-
mysql> SELECT REPEAT('MySQL',5);
+---------------------------+
| REPEAT('MySQL',5) |
+---------------------------+
| MySQLMySQLMySQLMySQLMySQL |
+---------------------------+
1 row in set (0.00 sec)
mysql> SELECT REPEAT('MySQL ',5);
+--------------------------------+
| REPEAT('MySQL ',5) |
+--------------------------------+
| MySQL MySQL MySQL MySQL MySQL |
+--------------------------------+
1 row in set (0.00 sec)
mysql> SELECT REPEAT('MySQL ',0);
+--------------------+
| REPEAT('MySQL ',0) |
+--------------------+
| |
+--------------------+
1 row in set (0.00 sec)
mysql> SELECT REPEAT('MySQL ',1);
+--------------------+
| REPEAT('MySQL ',1) |
+--------------------+
| MySQL |
+--------------------+
1 row in set (0.00 sec)
mysql> SELECT REPEAT('MySQL ',NULL);
+-----------------------+
| REPEAT('MySQL ',NULL) |
+-----------------------+
| NULL |
+-----------------------+
1 row in set (0.00 sec)
mysql> SELECT REPEAT(NULL,2);
+----------------+
| REPEAT(NULL,2) |
+----------------+
| NULL |
+----------------+
1 row in set (0.00 sec)
0 Comment(s)