Home >Database >Mysql Tutorial >What will MySQL return if the length of the original string is greater than the length of the argument specified in the LPAD() or RPAD() function?
In this case, MySQL will not pad anything and will truncate characters from the original string up to the length value provided in the LPAD() or RPAD() function .
mysql> Select LPAD('ABCD',3,'*'); +--------------------+ | LPAD('ABCD',3,'*') | +--------------------+ | ABC | +--------------------+ 1 row in set (0.00 sec) mysql> Select RPAD('ABCD',3,'*'); +--------------------+ | RPAD('ABCD',3,'*') | +--------------------+ | ABC | +--------------------+ 1 row in set (0.00 sec)
From the above example we can observe that both functions do not fill "*", but truncate the original string to the specified length, that is, the parameter is 3.
The above is the detailed content of What will MySQL return if the length of the original string is greater than the length of the argument specified in the LPAD() or RPAD() function?. For more information, please follow other related articles on the PHP Chinese website!