# What happens if the length of the original string is greater than the length of the string returned after padding in LPAD() or RPAD() functions?

MySQLMySQLi Database

In this case, MySQL will not pad anything and truncate the characters from the original string up to the value of length provided as the argument in LPAD() or RPAD() functions.

#### Example

mysql> Select LPAD('ABCD',3,'*');
+--------------------+
+--------------------+
| ABC                |
+--------------------+
1 row in set (0.00 sec)

+--------------------+
+--------------------+
| ABC                |
+--------------------+
1 row in set (0.00 sec)

We can observe from the above example that both the functions do not pad ‘*’ and truncate the original string up to the length specified i.e. 3 as the argument.

Published on 20-Feb-2018 13:07:36