REPEAT
The REPEAT function in SQL is used to repeat a string for a specified number of times.
Syntax
REPEAT(string, number)
Parameters
string: The string to be repeated.number: The number of times to repeat the string.
Return Value
The function returns a string which is the concatenation of the input string repeated the specified number of times.
Errors
- If the parameters are not in the correct format, a
TranslateError::FunctionArgsLengthNotMatchingerror will be returned. This function requires exactly two arguments. - If either
stringornumberare not string values, aEvaluateError::FunctionRequiresStringValueerror will be returned.
Examples
You can use the REPEAT function to repeat the name values:
SELECT REPEAT(name, 2) AS test FROM Item;
This will return:
hellohello
The 'hello' string is repeated twice as specified by the second parameter to the REPEAT function.