LPAD(number,number of digits,character)
LPAD is used to pad given character at left. If given number is 123 then total number of digit is 6. So appending three given characters to the left. In this example used to append zero to the prefix of the number.
SELECT LPAD(123,6,'0');
Returns 000123.
|
RPAD(number,number of digits,character)
RPAD is used to pad given character at right. If given number is 123 then total number of digit is 6. So appending three given characters to the right side.
SELECT RPAD(123,6,'x');
Returns 123xxx.
|
LPAD and RPAD method example
SELECT LPAD(123,6,'0');
SELECT RPAD(123,6,'x');
|