LPAD(str,len,padstr)
LPAD mysql funtion returns the string str, left-padded with the string padstr to a length of len characters means if you want to extend a string to a certain length and insert some character in left side of string at the place of sorten length then you can use LPAD function. The return value is shortened to len characters, If str is longer than len.
I am explaing this by some examples-
mysql> SELECT LPAD('Hello MySQL',15,'*');
+----------------------------+
| LPAD('Hello MySQL',15,'*') |
+----------------------------+
| ****Hello MySQL |
+----------------------------+
1 row in set (0.00 sec)
mysql> SELECT LPAD('Hello MySQL',9,'*');
+---------------------------+
| LPAD('Hello MySQL',9,'*') |
+---------------------------+
| Hello MyS |
+---------------------------+
1 row in set (0.00 sec)
0 Comment(s)