RTRIM() - Right-Trimming String

Q

How to trim off space characters from a string at the right end using the RTRIM() function?

✍: FYIcenter.com

A

RTRIM(str) is a MySQL built-in function that trims off space characters from a string at the right end. For example:

SET @str = 'dba.FYIcenter.com    ';

SELECT RTRIM(@str);
  -- +-------------------+
  -- | RTRIM(@str)       |
  -- +-------------------+
  -- | dba.FYIcenter.com |
  -- +-------------------+

Reference information of the RTRIM() function:

RTRIM(str): modstr
  Returns the string str with trailing space characters removed. Returns
  NULL if str is NULL.

Arguments, return value and availability:
  str: Required. The string that will be right-trimmed from.
  modstr: Return value. The modified string after trimming.
  Available since MySQL 4.0.

Related MySQL functions:

 

SOUNDEX() - Soundex Encoding

RPAD() - Right-Padding String

MySQL Functions on Character String Values

⇑⇑ MySQL Function References

2023-11-11, 239🔥, 0💬