Name

TRIM()

Synopsis

TRIM([specifier remove FROM] str)

Returns the string str with all remove prefixes or suffixes removed. The specifier can be one of BOTH, LEADING, or TRAILING. If no specifier is supplied, then BOTH is assumed. The remove string is optional and, if omitted, spaces are removed. This code returns the strings “No Padding” and “Hello__”:

SELECT TRIM('   No Padding   ');
SELECT TRIM(LEADING '_' FROM '__Hello__');

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