- Description: Pads the left side of a string with a specified character.
- Purpose: Formatting output to a specific length.
- Syntax:
LPAD(string, length, [pad_string])
- Parameters:
string
: The original string.length
: Desired total length after padding.pad_string
: Character to pad with (defaults to space).
- Returns: The padded string.
- Example:
LPAD('123', 5, '0')
returns'00123'
. - Notes: Truncates the original string if it exceeds the length.
- Use Case: Formatting IDs to a consistent width.
Leave a Reply