This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
dev:sql:functions:trim [2010/07/08 21:02] els |
dev:sql:functions:trim [2016/06/28 22:38] (current) |
||
|---|---|---|---|
| Line 4: | Line 4: | ||
| ===== Description ===== | ===== Description ===== | ||
| The TRIM function removes any leading and/or trailing pad characters from a string. The pad character is a single character and defaults to a space character. | The TRIM function removes any leading and/or trailing pad characters from a string. The pad character is a single character and defaults to a space character. | ||
| + | |||
| + | This function returns a STRING datatype. | ||
| ===== Syntax ===== | ===== Syntax ===== | ||
| Line 24: | Line 26: | ||
| ===== Examples ===== | ===== Examples ===== | ||
| - | ==== Example 1 ==== | + | ==== Example 1: Column ==== |
| - | <code SQL> | + | <code> |
| > select trim(name) from individuals; | > select trim(name) from individuals; | ||
| Line 38: | Line 40: | ||
| KATHLEEN TUCKER | KATHLEEN TUCKER | ||
| </code> | </code> | ||
| - | ==== Example 2 ==== | + | ==== Example 2: Column with LEADING ==== |
| - | <code SQL> | + | <code> |
| > select individual, trim(leading '0' from individual) ind from individuals; | > select individual, trim(leading '0' from individual) ind from individuals; | ||
| Line 53: | Line 55: | ||
| 000900240828 900240828 | 000900240828 900240828 | ||
| </code> | </code> | ||
| - | ==== Example 3 ==== | + | ==== Example 3: Complex expression ==== |
| The following complex example creates a string containing the name and an optional email. | The following complex example creates a string containing the name and an optional email. | ||
| - | <code SQL> | + | <code> |
| > Select (((trim($proper(NAME)) || | > Select (((trim($proper(NAME)) || | ||
| >> case | >> case | ||
| Line 79: | Line 81: | ||
| Kathleen Tucker | Kathleen Tucker | ||
| </code> | </code> | ||
| + | ====== Additional Resources ====== | ||
| + | |||
| + | See also: | ||
| + | {{page>dev:sql:functions:see_also_string&nofooter&noeditbtn&noheader}} | ||
| + | |||
| {{page>:bottom_add&nofooter&noeditbtn}} | {{page>:bottom_add&nofooter&noeditbtn}} | ||