Name

LTRIM() and RTRIM()

Synopsis

LTRIM(str) and RTRIM(str)

The function LTRIM returns the string str with any leading spaces removed, while the function RTRIM performs the same action on the string’s tail. This code returns the strings “No Padding” and “No Padding”:

SELECT LTRIM('   No Padding   ');
SELECT RTRIM('   No Padding   ');

Get Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition 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.