Curriculum
Course: MYSQL
Login

Curriculum

MYSQL

MySQL References

0/140
Text lesson

RPAD

Example

Pad the string on the right side with “ABC” until it reaches a total length of 20 characters.

SELECT RPAD(“SQL Tutorial”, 20“ABC”); 

Definition and Usage

The RPAD() function adds padding to the right side of a string with another string until it reaches a specified length.

Note: Additionally, consider the LPAD() function for padding on the left side.

Syntax

RPAD(stringlengthrpad_string)

Parameter Values

Parameter

Description

string

Input required: The original string. If the length of the original string exceeds the length parameter, this function removes any overflowing characters from the string.

length

Input required: The desired length of the string after right-padding has been applied.

rpad_string

Input required: The string used for right-padding.

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Pad the text in the “CustomerName” column on the right side with “ABC” until it reaches a total length of 30 characters.

SELECT RPAD(CustomerName, 30“ABC”AS RightPadCustomerName
FROM Customers;