Name

LPAD( )

Synopsis

LPAD(string, length, padding)

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

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

In this example, a list of three courses is retrieved and the results are padded with dots to the left of the course names.

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.