~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Other String Functions
 
2
======================
 
3
 
 
4
.. _coercibility-function:
 
5
 
 
6
COERCIBILITY
 
7
------------
 
8
 
 
9
Gets coercibility for an expression.
 
10
 
 
11
.. _elt-function:
 
12
 
 
13
ELT
 
14
---
 
15
 
 
16
Return string at index number.
 
17
 
 
18
.. _export-set-function:
 
19
 
 
20
EXPORT_SET
 
21
----------
 
22
 
 
23
Return a string
 
24
 
 
25
.. _format-function:
 
26
 
 
27
FORMAT
 
28
------
 
29
 
 
30
Return a number formatted to specified number of decimal places.
 
31
 
 
32
.. _load-file-function:
 
33
 
 
34
LOAD_FILE
 
35
---------
 
36
 
 
37
Load the named file.
 
38
 
 
39
.. _lpad-function:
 
40
 
 
41
LPAD
 
42
----
 
43
 
 
44
Return the string argument, left-padded with the specified string.
 
45
 
 
46
.. _make-set-function:
 
47
 
 
48
MAKE_SET
 
49
--------
 
50
 
 
51
Return a set of comma-separated strings that have the corresponding bit in bits set.
 
52
 
 
53
.. _match-function:
 
54
 
 
55
MATCH
 
56
-----
 
57
 
 
58
Perform full-text search.
 
59
 
 
60
.. _mid-function:
 
61
 
 
62
MID
 
63
---
 
64
 
 
65
Return a substring starting from the specified position.
 
66
 
 
67
.. _quote-function:
 
68
 
 
69
QUOTE
 
70
-----
 
71
 
 
72
Escape the argument for use in an SQL statement.
 
73
 
 
74
.. _repeat-function:
 
75
 
 
76
REPEAT
 
77
------
 
78
 
 
79
Repeat a string the specified number of times.
 
80
 
 
81
.. _replace-function:
 
82
 
 
83
REPLACE
 
84
-------
 
85
 
 
86
The REPLACE() function returns a string with all occurrences of the 'from_str' replaced by 'to_str'. REPLACE is case-sensitive when searching for 'from_str'.
 
87
 
 
88
Syntax:
 
89
 
 
90
REPLACE(str,from_str,to_str)
 
91
 
 
92
For example:
 
93
 
 
94
.. code-block:: mysql
 
95
        
 
96
        SELECT REPLACE('www.google.com', 'w', 'v');
 
97
 
 
98
Returns: vvv.google.com
 
99
 
 
100
.. _reverse-function:
 
101
 
 
102
REVERSE
 
103
-------
 
104
 
 
105
This function returns a string argument with the characters in reverse order.
 
106
 
 
107
.. code-block:: mysql
 
108
 
 
109
        SELECT REVERSE('abcd');
 
110
 
 
111
Returns: dcba
 
112
 
 
113
.. _right-function:
 
114
 
 
115
RIGHT
 
116
-----
 
117
 
 
118
Return the specified rightmost number of characters
 
119
 
 
120
.. _rpad-function:
 
121
 
 
122
RPAD
 
123
----
 
124
 
 
125
Append string the specified number of times
 
126
 
 
127
.. _soundex-function:
 
128
 
 
129
SOUNDEX
 
130
-------
 
131
 
 
132
Return a soundex string
 
133
 
 
134
.. _substr-function:
 
135
 
 
136
SUBSTR
 
137
------
 
138
 
 
139
Synonym for SUBSTRING().
 
140
 
 
141
.. _substring-function:
 
142
 
 
143
SUBSTRING
 
144
---------
 
145
 
 
146
Returns the substring as specified
 
147
 
 
148
Examples that use SUBSTRING() in the SELECT clause:
 
149
 
 
150
The SUBSTRING() function is used to extract a character string (using a given starting position and a given length).
 
151
 
 
152
.. code-block:: mysql
 
153
 
 
154
        SELECT  
 
155
        SUBSTRING(course_designater,6,3) as 'Course number'                   
 
156
        FROM Courses
 
157
        WHERE course_designater LIKE 'Excel%' 
 
158
        LIMIT 10;    
 
159
 
 
160
You can also format a column using SUBSTRING() in combination with functions like LOWER() and UPPER().
 
161
 
 
162
.. code-block:: mysql
 
163
 
 
164
        SELECT 
 
165
        CONCAT(UPPER(SUBSTRING(lastname,1,1)),
 
166
        LOWER(SUBSTRING(lastname,2,29)))
 
167
        FROM Students
 
168
        LIMIT 10;
 
169
 
 
170
.. _substring-index-function:
 
171
 
 
172
 
 
173
SUBSTRING_INDEX
 
174
---------------
 
175
 
 
176
Return a substring from a string before the specified number of occurrences of the delimiter.