Beginner

313. LTRIM Function

Learn how to remove unwanted characters or spaces from the beginning of a string.

📘 Lesson 313 of 728 ⏱ 8 min 🎯 Beginner

The LTRIM function removes leading spaces, and in some database systems specified leading characters, from a string.

Leading spaces can make otherwise identical values behave differently during comparisons and data analysis.

Remove leading spaces from employee names.

SQL
SELECT
    LTRIM(EmployeeName) AS CleanEmployeeName
FROM Employees;

LTRIM is useful for cleaning imported files, text fields, identifiers, and customer information.

  • LTRIM removes leading spaces.
  • It cleans the beginning of strings.
  • It is useful for imported data.
  • It can improve text comparisons.
  • Exact character-removal syntax varies.
What does LTRIM do?

LTRIM removes unwanted leading spaces from a string.

How is LTRIM different from TRIM?

LTRIM focuses on the beginning of a string, while TRIM generally removes unwanted characters from both ends.

Have you finished this lesson?

Introduction to SQL – All Lessons