REPEAT
Repeats a string the given number of times.
MySQL 8.1
REPEAT(str, count)Parameters
- strVARCHAR
- String to repeat
- countINT
- Number of repetitions
Return value
A string of count repetitions of str; an empty string if count is less than 1
Examples
String three times in a row
MySQL 8.1
SELECT REPEAT('ab', 3);Stars for a review rating
MySQL 8.1
SELECT reservation_id,
rating,
REPEAT('*', rating) AS stars
FROM Reviews
LIMIT 5;