How to repeat the values stored in a data column of MySQL table?



For repeating the values stored in a data column of MySQL table, the name of the column must be passed as the first argument of REPEAT() function. The data from ‘Student’ table is used to demonstrate it:

Example

mysql> Select REPEAT(Name,3)AS Name from student;
+-----------------------+
| Name                  |
+-----------------------+
| GauravGauravGaurav    |
| AaravAaravAarav       |
| HarshitHarshitHarshit |
| GauravGauravGaurav    |
| YashrajYashrajYashraj |
+-----------------------+
5 rows in set (0.00 sec)

Advertisements