~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/functions/string/modification.rst

  • Committer: Lee Bieber
  • Date: 2011-02-24 03:20:47 UTC
  • mfrom: (2196.1.4 build)
  • Revision ID: kalebral@gmail.com-20110224032047-avmw06iwww3m73cw
Merge Andrew - 723653: Docs day first pass fixes 
Merge Brian - Puts back in support for COM_KILL, Also adds back in the INTERACTIVE flag, and creates a DD to track sessions/check on usage
Merge Olaf - Use List::size()

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
------
6
6
 
7
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. 
 
8
The CONCAT(str1, str2...) function can have one or more arguments. It returns a string that is the result of concatenating the arguments.
9
9
 
10
10
* If arguments are non-binary strings, the result is also a non-binary string.
11
11
* If any argument is a binary string, then the result will also be a binary string. 
14
14
 
15
15
Syntax:
16
16
 
17
 
CONCAT(str1, str2, [,...n])

18
 
For example: ::
      
 
17
CONCAT(str1, str2, [,...n])
 
18
For example:
 
19
 
 
20
.. code-block:: mysql
 
21
 
19
22
        SELECT CONCAT('Dr', 'izzl', 'ed');
20
23
 
21
 
Returns: 'Drizzled' ::
 
24
Returns: 'Drizzled'
 
25
 
 
26
.. code-block:: mysql
22
27
 
23
28
        SELECT CONCAT('micro', NULL, 'nel');
24
29
 
25
 
Returns: NULL ::
 
30
Returns: NULL
 
31
 
 
32
.. code-block:: mysql
26
33
 
27
34
        SELECT CONCAT(14.8);
28
35
 
29
36
Returns: '14.8'
30
37
 
31
38
CONCAT_WS
32
 
---------

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. 
 
39
---------
 
40
CONCAT WS (With Separator) [1]_ 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.
34
41
 
35
 
* If the separator is NULL then the result is NULL.

36
42
Syntax:
37
43
 
38
 
CONCAT_WS(separator str1, str2,....) 
39
 
 
40
 
For example:
      
 
44
CONCAT_WS(separator str1, str2,....)
 
45
 
 
46
For example:
 
47
 
 
48
.. code-block:: mysql
 
49
 
41
50
        SELECT CONCAT_WS(',', ' Occupation', 'First name', 'Last Name');
42
51
 
43
52
Returns: 'Occupation, First name, Last Name'
44
53
 
 
54
.. code-block:: mysql
 
55
 
45
56
        SELECT CONCAT_WS(',', 'First name', NULL, 'Last Name');
46
57
 
47
58
Returns: 'First name, Last Name'
48
59
 
49
60
 
50
61
TRIM()
51
 
------         
 
62
------
52
63
 
53
64
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.
54
65
 
69
80
 
70
81
This version of the TRIM function removes trailing spaces from the end of a function. 
71
82
 
 
83
.. rubric:: Footnotes
 
84
 
 
85
.. [1] If the separator is NULL then the result is NULL.