Syntax
RPAD(str,len,padstr)
Purpose
RPAD() right-pads the str string with the padstr string to a length of len characters.
If the length of
strexceedslen, then the leftmostlencharacters ofstrare returned.If the length of
stris less thanlenbut the length ofstrright-padded withpadstris greater thanlen, then the leftmostlencharacters of the string generated after padding are returned.If the length of
stris less thanlenand the length ofstrright-padded withpadstris still less thanlen, thenstris right-padded with multiplepadstrstrings until the length is greater than or equal tolen, and the leftmostlencharacters of the string generated after padding 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