LPAD()
LPAD(str
,len
,padstr
)
Returns the string str
padded to a
length of len
characters by prepending the
string with padstr
characters. If
str
is longer than
len
, the string returned will be truncated
to len
characters. This code:
SELECT LPAD('January', '8', ' '); SELECT LPAD('February', '8', ' '); SELECT LPAD('March', '8', ' '); SELECT LPAD('April', '8', ' '); SELECT LPAD('May', '8', ' ');
returns the following strings:
January February March April May
Notice how all the strings have been padded to be eight characters long.