LPAD()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a string left-padded with the specified characters.
USAGE
LPAD(string, width, padding)
Argument Name | Description |
---|---|
| The string to be padded |
| The desired width of the resulting string |
| The string that is used for padding |
DETAILS
LPAD()
is a string function that returns a string left-padded in a field of the specified width using the specified padding string.
A string that is longer than the specified width is shortened to fit within the width.
A string that is shorter than the specified width has the remainder of the field with filled in with the padding characters, which are repeated if they are shorter than the needed padding length.
A NULL
is returned if any argument is NULL
.
EXAMPLES
SELECT LPAD('Example', 15, '. ') AS result;
+-----------------+
| result |
+-----------------+
| . . . . Example |
+-----------------+
SELECT LPAD('Example', 2, '~') AS r;
+------+
| r |
+------+
| Ex |
+------+
SELECT LPAD('FOO', 42, '_.~"~._.~"~._.~"~._.~"~.') AS result;
+--------------------------------------------+
| result |
+--------------------------------------------+
| _.~"~._.~"~._.~"~._.~"~._.~"~._.~"~._.~FOO |
+--------------------------------------------+