SQL LTRIM() Function

Last Updated : 13 Apr, 2026

The LTRIM() function in SQL is an inbuilt string function used to remove leading spaces from the left side of a string. It can also be used to remove specific characters from the beginning of the string.

  • The LTRIM function is used to clean data in databases.
  • It removes unnecessary leading characters or spaces from text values.
  • Data administrators use it to streamline data cleaning tasks efficiently in one go.

Syntax:

LTRIM(Input_String, [Trim_Characters])
  • Input_String: String from which you want to remove leading spaces.
  • Trim_Characters: [optional] specified characters you want to remove.

Note: If we don't specify any characters to remove, the LTRIM function removes the white spaces for data cleaning and manipulation in SQL.

Query:

Select LTRIM('     GeeksforGeeks.') AS trimmedString; 

Output:

Screenshot-2025-11-21-155130
Output after LTrim()

Examples of SQL LTRIM()

Now let us see some examples of LTRIM function in different use cases to understand it's working better:

Example 1: Remove Specific Characters Using LTRIM Function

In this example, we will remove specific characters using LTRIM function.

Query:

SELECT LTRIM('----GeeksforGeeks', '-') AS TrimmedString;

Output:

Screenshot-2025-11-21-155436
Output after LTrim()
  • Removes the - characters from the left side of the string.
  • Returns the cleaned result as TrimmedString.

Example 2: Remove a Substring from a String Using LTRIM Function

In this example, we will remove a substring from a string using the LTRIM function.

Query:

SELECT LTRIM('GeeksforGeeks', 'Geeks') AS TrimmedString;

Output:

Screenshot-2025-11-21-155508
Output after LTrim()
  • Removes the specified characters ‘Geeks’ from the left side of the string.
  • Returns the remaining string as TrimmedString.

Example 3: Use LTRIM on a Table Column

Let us create a table where the names of the users are stored with whitespaces. If we want to remove these whitespaces then we can use the LTRIM in SQL to remove them in one go.

Query:

CREATE TABLE Users (
Name VARCHAR(45)
);
INSERT INTO Users (Name) VALUES
(' Alice'), (' Bob'), (' Charlie'), (' David'), (' Eve');

Output:

Screenshot-2025-11-21-155628
Users Table

Now to remove whitespace from this column, we can use the SQL query:

SELECT  LTRIM(Name) AS TrimmedNames
FROM Users;

Output:

Screenshot-2025-11-21-155805
Output after LTrim()
  • Removes leading (left-side) spaces from the Name column.
  • Displays the cleaned values as TrimmedNames.