This tutorial explains how to use the MySQL RPAD function with syntax and examples.
The MySQL RPAD function returns a string that is right-padded with a specified string to a certain length.
The syntax for the RPAD function in MySQL is:
RPAD( string, length, pad_string )
The string to right-pad.
The length of the result after string has been right-padded.
The specified string to right-pad to string.
The RPAD function can be used in the following versions of MySQL:
Let's look at some MySQL RPAD function examples and explore how to use the RPAD function in MySQL.
For example:
mysql> SELECT RPAD('AODBA.com', 18, 'A');
Output: 'AODBA.comAA'
mysql> SELECT RPAD('AODBA.com', 19, 'A');
Output: 'AODBA.comAAA'
mysql> SELECT RPAD('abc', 6, ' ');
Output: 'abc '
mysql> SELECT RPAD('abc', 9, 'XYZ');
Output: 'abcXYZXYZ'
mysql> SELECT RPAD('abc', 10, 'XYZ');
Output: 'abcXYZXYZX'