Name

RTRIM( )

Synopsis

RTRIM(string)

This function returns the string given with any trailing spaces removed.

UPDATE students
SET name_last = RTRIM(name_last);

In this example, the last names of several students have been entered inadvertently with a space at the end of the names. This SQL statement will remove any trailing spaces from each name retrieved and then write 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.