Knowledge Walls
John Peter
Pune, Maharashtra, India
How to use LPAD and RPAD method in mysql with example?
3632 Views
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');
Best Lessons of "One day One Thing to Know"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details