1
String Modification Functions
2
=============================
7
The SQL standard defines a concatenation operator ( || ), which joins two or more strings into one string value.
8
The CONCAT(str1, str2….) function can have one or more arguments. It returns a string that is the result of concatenating the arguments.
10
* If arguments are non-binary strings, the result is also a non-binary string.
11
* If any argument is a binary string, then the result will also be a binary string.
12
* Numeric arguments are converted to their equivalent in binary string format.
13
* If any argument is NULL then it also returns NULL.
17
CONCAT(str1, str2, [,...n])
19
SELECT CONCAT('Dr', 'izzl', 'ed');
21
Returns: 'Drizzled' ::
23
SELECT CONCAT('micro', NULL, 'nel');
33
CONCAT WS (With Separator) allows you to specify that the first argument is treated as a separator for the rest of the arguments. This argument is added between the strings to be concatenated.
35
* If the separator is NULL then the result is NULL.
38
CONCAT_WS(separator str1, str2,....)
41
SELECT CONCAT_WS(',', ' Occupation', 'First name', 'Last Name');
43
Returns: 'Occupation, First name, Last Name'
45
SELECT CONCAT_WS(',', 'First name', NULL, 'Last Name');
47
Returns: 'First name, Last Name'
53
The TRIM function remove specified prefixes or suffixes from a string (typically leading and trailing spaces), and returns the resulting string. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed.
57
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)
59
[remstr] is optional (if it's not specified, spaces are removed).
64
This version of the TRIM function removes leading spaces from the beginning of a string.
70
This version of the TRIM function removes trailing spaces from the end of a function.