Name
RPAD()
Synopsis
RPAD(string
,length
,padding
)
This function adds padding
to the
right end of string
, stopping if the
combination of string
and the added padding
reach length
characters. If the length
given is shorter than the length of the string, the string will be
shortened to comply with the length constraint. The padding can be any
character. Here is an example:
SELECT RPAD(course_name, 25, '.') AS Courses FROM courses WHERE course_code LIKE 'ENGL%' LIMIT 3; +---------------------------+ | Courses | +---------------------------+ | Creative Writing......... | | Professional Writing..... | | American Literature...... | +---------------------------+
This statement presents a list of three course names that are retrieved. Each row of the results is padded with dots to the right.
Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.