TRIM

From SQLZoo
Compatibility
TRIM(s)
EngineOKAlternative
ingresYes
mysqlYes
oracleYes
postgresYes
sqlserverNoLTRIM(RTRIM(s))

TRIM

TRIM(s) returns the string with leading and trailing spaces removed.

   TRIM('Hello world  ') -> 'Hello world'

This function is particularly useful when working with CHAR fields. Typically a CHAR field is paddded with spaces. In contrast a VARCHAR field does not require padding.

SELECT name,
       LTRIM(RTRIM(name))
  FROM bbc
SELECT name,
       TRIM(name)
  FROM bbc

See also

DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects
  • Your server today is: Dipsy