CodesJava

Easy learning with example program codes

LPAD() FUNCTION in MySQL

LPAD() FUNCTION
The MySQL LPAD function is used to get a string that is left-padded with a specified string. This padding can also be limited to a certain length. The various versions of MySQL supports the LPAD function, namely, MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0 and MySQL 3.23.

Syntax:

LPAD( string, length, pad_string )

Parameters:
string: It is used to specify the string to modify.
length: It is used to specify the length of the resulting string.
pad_string: It is used to specify the string to pad with.

Example:

mysql> SELECT LPAD ( 'HELLO', 10123);

Output:

 '12312HELLO’

Explanation:
The string is left-padded with the specified string to create a string of 10 characters in length.

Please follow and like us:
error









Copyright © 2019 CodesJava DMCA.com Protection Status