REPEAT()

Description

Returns a string consisting of the string str repeated count times. If count is less than 1, returns an empty string. Returns NULL if str or count is NULL.

Syntax

  1. > REPEAT(str,count)

Arguments

ArgumentsDescription
strRequired. The string to repeat.
countRequired. The number of times to repeat.

Examples

  1. mysql> SELECT repeat('abc', -1);
  2. +-----------------+
  3. | repeat(abc, -1) |
  4. +-----------------+
  5. | |
  6. +-----------------+
  7. 1 row in set (0.00 sec)
  8. mysql> SELECT repeat('abc', 1), repeat('abc', 2), repeat('abc', 3);
  9. +----------------+----------------+----------------+
  10. | repeat(abc, 1) | repeat(abc, 2) | repeat(abc, 3) |
  11. +----------------+----------------+----------------+
  12. | abc | abcabc | abcabcabc |
  13. +----------------+----------------+----------------+
  14. 1 row in set (0.00 sec)