MySQL LTRIM() Function

In MySQL, the LTRIM() function removes leading spaces from the specified string and returns the string without leading spaces.

If you want to remove trailing spaces from a string, you can use the RTRIM() or TRIM().

LTRIM() Syntax

Here is the syntax of MySQL LTRIM() function:

LTRIM(str)

Parameters

str
Required. The string to be trimmed.

Return value

The LTRIM() function returns a string with leading spaces removed.

If the parameter is NULL, the function will return NULL.

LTRIM() Examples

Here are some examples of MySQL LTRIM() function.

SELECT
    LTRIM('   Hello '),
    LTRIM(NULL);
+--------------------+--------------------------+
| LTRIM('   Hello ') | LTRIM(NULL)              |
+--------------------+--------------------------+
| Hello              | NULL                     |
+--------------------+--------------------------+