LPAD
You are viewing an old version of this article. View
the current version here.
Syntax
LPAD(str, len [,padstr])
Description:
Returns the string str
, left-padded with the string padstr
to a length
of len
characters. If str
is longer than len
, the return value is
shortened to len
characters. If padstr
is omitted, the LPAD function pads spaces.
Prior to the version 10.3.1, the padstr
parameter was mandatory.
Examples
SELECT LPAD('hello',10,'.'); +----------------------+ | LPAD('hello',10,'.') | +----------------------+ | .....hello | +----------------------+ SELECT LPAD('hello',2,'.'); +---------------------+ | LPAD('hello',2,'.') | +---------------------+ | he | +---------------------+
See also
- RPAD() ; Returns the string right-padded with another string to a given length
Comments
Comments loading...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.