LTRIM() Function in MySQL

Last Updated : 17 Aug, 2026

The LTRIM() function in MySQL removes leading spaces from the left side of a string.

  • Removes leading spaces from text
  • Useful for cleaning string data.
  • Helps standardize text values in databases.

Syntax

LTRIM(string);
  • string: The string from which leading spaces are removed.

Example:

SELECT LTRIM('     GeeksforGeeks') AS trimmedString;

Output:

Screenshot-2026-08-14-162619

Example: LTRIM() on a Table Column

Create a table with names containing leading spaces:

CREATE TABLE users (
    name VARCHAR(45)
);

INSERT INTO users (name) VALUES
('   Alice'),
('   Bob'),
('   Charlie'),
('   David'),
('   Eve');

To remove the leading spaces:

SELECT LTRIM(name) AS trimmedName
FROM users;

Output:

Screenshot-2026-08-14-162926
  • Here, LTRIM() removes the leading spaces from the name column.
Comment

Explore