LPAD(string,length,padding)

Description: Returns string with its length increased to length characters by padding out to the left with padding.

If string is longer than length, it will be shortened to that length.

Examples:

  • LPAD('Tony',5,'*') returns *Tony.

  • LPAD('Tony',2,'*') returns To.

  • LPAD('Tony',20,'* ') returns * * * * * * * * Tony.

See also: RPAD()

Get Sams Teach Yourself MySQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.