Collections:
LPAD() - Left-Padding String
How to pad a string at the left end using the LPAD() function?
✍: FYIcenter.com
LPAD(str, len, padstr) is a MySQL built-in function that
truncates a string or pad it at the left end to a given length.
For example:
SET @str = 'ops'; SELECT LPAD(@str, 6, 'o'); -- +--------------------+ -- | LPAD(@str, 6, 'o') | -- +--------------------+ -- | oooops | -- +--------------------+
Reference information of the LPAD() function:
LPAD(str, len, padstr): modstr Returns the string str, left-padded with the string padstr to a length of len characters. If str is longer than len, the return value is shortened to len characters. It returns NULL if any of its arguments are NULL. Arguments, return value and availability: str: Required. The string that will be searched in. len: Required. The number of characters to be truncated or left-padded to. padstr: Required. The substring to pad with. modstr: Return value. The modified string after truncating or padding. Available since MySQL 4.0.
Related MySQL functions:
⇒ LTRIM() - Left-Trimming String
⇐ LOWER() - Convert String to Lower Case
2023-11-12, 1038🔥, 0💬
Popular Posts:
How To Use DATEADD() Function in SQL Server Transact-SQL? DATEADD() is a very useful function for ma...
What Happens If the UPDATE Subquery Returns Multiple Rows in MySQL? If a subquery is used in a UPDAT...
How To Connect the Oracle Server as SYSDBA in Oracle? This is Step 4. The best way to connect to the...
How To Get a List of All Tables with "sys.tables" View in SQL Server? If you want to see the table y...
How To Drop an Index in Oracle? If you don't need an existing index any more, you should delete it w...