Name

RPAD( )

Synopsis

RPAD(string, length, padding)

This function adds padding specified in the third argument of the function to left end of the string given in the first argument, until the maximum length (second argument) of string and padding combined is reached.

SELECT RPAD(course_name, 25, '.') AS Courses
FROM courses LIMIT 3;
+---------------------------+
| Courses                   |
+---------------------------+
| Creative Writing......... |
| Professional Writing..... |
| American Literature...... |
+---------------------------+

This SQL statement presents a list of three course names that are retrieved. The results are padded with dots to the right of each.

Get MySQL in a Nutshell 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.