Syntax
RPAD(str,len,padstr)
Purpose
The RPAD function pads the string str with the string padstr on the right until the length of the result is len.
If the length of
stris greater thanlen, the leftmostlencharacters ofstrare returned.If the length of
stris less thanlen, and the combined length ofstrandpadstris greater thanlen, the leftmostlencharacters of the combined string are returned.If the length of
stris less thanlen, and the combined length ofstrandpadstris less thanlen, the leftmostlencharacters of the combined string ofstrand multiple repetitions ofpadstr(total length greater than or equal tolen) are returned.
Examples
obclient> SELECT RPAD('hi',5,'?');
+------------------+
| RPAD('hi',5,'?') |
+------------------+
| hi??? |
+------------------+
1 row in set
obclient> SELECT RPAD('hi',1,'?');
+------------------+
| RPAD('hi',1,'?') |
+------------------+
| h |
+------------------+
1 row in set
