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'
52
Remove leading and trailing spaces
54
LTRIM() Remove leading spaces
57
RTRIM() Remove trailing spaces