MySQL RPAD() Function
Example
Right-pad the string with "ABC", to a total length of 20:
SELECT RPAD("SQL Tutorial", 
  20, "ABC");
Try it Yourself »
Definition and Usage
The RPAD() function returns a string that is right-padded with a specified string to a certain length.
Note: Also look at the LPAD() function.
Syntax
  RPAD(string, 
  length, pad_string)Parameter Values
| Parameter | Description | 
|---|---|
| string | Required. The string to right-pad | 
| length | Required. The length of the string after it has been right-padded | 
| pad_string | Required. The string to right-pad to string | 
Note: If string is longer than length, the RPAD() function will remove the over floating characters from string.
Technical Details
| Works in: | MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23 | 
|---|
More Examples
Example
Right-pad the text in "CustomerName" with "ABC", to a total length of 30:
  SELECT 
  RPAD(CustomerName, 30, "ABC") AS RightPadCustomerName
FROM Customers; 
Try it Yourself »

