LTRIM() FUNCTION in MySQL

LTRIM() FUNCTION
The MySQL LTRIM function is used to remove all space characters from the left-hand side of a string. The various versions of MySQL support the LTRIM 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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
LTRIM( string )
LTRIM( string )
LTRIM( string )

Parameters:
string: It is used to specify the string to modify.

Example 1:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mysql> SELECT LTRIM ( ' HELLO' );
mysql> SELECT LTRIM ( ' HELLO' );
mysql> SELECT LTRIM ( '  HELLO' );

Output:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
'HELLO’
'HELLO’
 'HELLO’

Explanation:
All the space characters are removed from the left-hand side of the string.

Example 2:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mysql> SELECT LTRIM ( ' HELLO ' );
mysql> SELECT LTRIM ( ' HELLO ' );
mysql> SELECT LTRIM ( '  HELLO  ' );

Output:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
'HELLO ’
'HELLO ’
 'HELLO  ’

Explanation:
All the space characters are removed from the left-hand side of the string.