Name

LTRIM( )

Synopsis

LTRIM(string)

The function returns a string given with any leading spaces removed.

UPDATE students
SET name_last = LTRIM(name_last);

In this example, the last names of several students have been entered inadvertently with a space in front of the names. This SQL statement removes any leading spaces from each name retrieved and then writes the trimmed text over the existing data.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.