Difference between revisions of "TRIM"

From SQLZOO
Jump to: navigation, search
(Created page with "<table align='right' border='1'> <caption>Compatibility</caption> <tr><th colspan='3'>TRIM(s)</th></tr> <tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''</td...")
 
 
Line 34: Line 34:
 
<p>See also</p>
 
<p>See also</p>
 
<ul>
 
<ul>
   <li>[[SUBSTRING function]]</li>
+
   <li>[[SUBSTRING |SUBSTRING function]]</li>
   <li>[[LEFT function]]</li>
+
   <li>[[LEFT |LEFT function]]</li>
   <li>[[RIGHT function]]</li>
+
   <li>[[RIGHT |RIGHT function]]</li>
 
</ul>
 
</ul>

Latest revision as of 16:29, 16 July 2012

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

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense