~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-11 20:30:05 UTC
  • mfrom: (2157.1.3 build)
  • Revision ID: kalebral@gmail.com-20110211203005-757o1y2yf78dxzqr
Merge Stewart - 716848: drizzleimport displays wrong program_name
Merge Stewart - update README file
Merge Andrew and Joe - Exposes the InnoDB SYS_REPLICATION_LOG to data_dictionary so that it is fast and fixes many issues we have been having

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
String Modification Functions
2
 
=============================
3
 
 
4
 
CONCAT
5
 
------
6
 
 
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. 
9
 
 
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. 
14
 
 
15
 
Syntax:
16
 
 
17
 
CONCAT(str1, str2, [,...n])

18
 
For example: ::
      
19
 
        SELECT CONCAT('Dr', 'izzl', 'ed');
20
 
 
21
 
Returns: 'Drizzled' ::
22
 
 
23
 
        SELECT CONCAT('micro', NULL, 'nel');
24
 
 
25
 
Returns: NULL ::
26
 
 
27
 
        SELECT CONCAT(14.8);
28
 
 
29
 
Returns: '14.8'
30
 
 
31
 
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. 
34
 
 
35
 
* If the separator is NULL then the result is NULL.

36
 
Syntax:
37
 
 
38
 
CONCAT_WS(separator str1, str2,....) 
39
 
 
40
 
For example:
      
41
 
        SELECT CONCAT_WS(',', ' Occupation', 'First name', 'Last Name');
42
 
 
43
 
Returns: 'Occupation, First name, Last Name'
44
 
 
45
 
        SELECT CONCAT_WS(',', 'First name', NULL, 'Last Name');
46
 
 
47
 
Returns: 'First name, Last Name'
48
 
 
49
 
 
50
 
TRIM()
51
 
------         
52
 
 
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.
54
 
 
55
 
Syntax:
56
 
 
57
 
TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)
58
 
 
59
 
[remstr] is optional (if it's not specified, spaces are removed).
60
 
 
61
 
LTRIM()
62
 
-------
63
 
 
64
 
This version of the TRIM function removes leading spaces from the beginning of a string.
65
 
 
66
 
 
67
 
RTRIM()
68
 
-------
69
 
 
70
 
This version of the TRIM function removes trailing spaces from the end of a function. 
71