Tuesday, 10 July 2018

Mysql REPEAT() function

Mysql REPEAT() function

MySQL REPEAT() repeats a string for a specified number of times. Both the string and the number of times that string to be repeated are supplied as arguments.
The function returns NULL either any of the arguments is NULL.
Syntax:
REPEAT(str, count)
Arguments
NameDescription
strA string which is to be repeated.
countAn integer indicating how many times the string str is to be repeated.
MySQL Version: 5.6
Example: MySQL REPEAT() function
The following MySQL statement repeats the string ‘**-‘ 15 times.
Code:
SELECT REPEAT('**-',15); 


Sample Output:
mysql> SELECT REPEAT('**-',15); 
+-----------------------------------------------+
| REPEAT('**-',15)                              |
+-----------------------------------------------+
| **-**-**-**-**-**-**-**-**-**-**-**-**-**-**- | 
+-----------------------------------------------+
1 row in set (0.03 sec)

0 comments:

Post a Comment