~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2011-02-12 06:13:32 UTC
  • mto: This revision was merged to the branch mainline in revision 2161.
  • Revision ID: brian@tangent.org-20110212061332-a5dtetim82r6vvls
Merge in session up and out of sql_select.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Other String Functions
2
 
======================
3
 
 
4
 
LOAD_FILE()
5
 
-----------
6
 
 
7
 
Load the named file
8
 
 
9
 
ELT()
10
 
-----
11
 
 
12
 
Return string at index number
13
 
 
14
 
EXPORT_SET()
15
 
------------
16
 
 
17
 
Return a string
18
 
 
19
 
FORMAT()
20
 
--------
21
 
 
22
 
Return a number formatted to specified number of decimal places
23
 
 
24
 
LOAD_FILE()
25
 
-----------
26
 
 
27
 
Load the named file
28
 
 
29
 
LPAD()
30
 
-------
31
 
 
32
 
Return the string argument, left-padded with the specified string
33
 
 
34
 
MAKE_SET()
35
 
----------
36
 
 
37
 
Return a set of comma-separated strings that have the corresponding bit in bits set
38
 
 
39
 
MATCH()
40
 
-------
41
 
 
42
 
Perform full-text search
43
 
 
44
 
MID()
45
 
-----
46
 
 
47
 
Return a substring starting from the specified position
48
 
 
49
 
ORD()
50
 
-----
51
 
 
52
 
Return character code for leftmost character of the argument
53
 
 
54
 
QUOTE()
55
 
-------
56
 
 
57
 
Escape the argument for use in an SQL statement
58
 
 
59
 
REPEAT()
60
 
--------
61
 
 
62
 
Repeat a string the specified number of times
63
 
 
64
 
REPLACE()
65
 
---------
66
 
 
67
 
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'.
68
 
 
69
 
Syntax:
70
 
 
71
 
REPLACE(str,from_str,to_str)
72
 
 
73
 
For example: ::
74
 
        
75
 
        SELECT REPLACE('wwww.google.com', 'w', 'v');
76
 
 
77
 
Returns: vvv.google.com
78
 
 
79
 
REVERSE()
80
 
---------
81
 
 
82
 
This function returns a string argument with the characters in reverse order. ::
83
 
 
84
 
        SELECT REVERSE('abcd');
85
 
 
86
 
Returns: dcba
87
 
 
88
 
RIGHT()
89
 
-------
90
 
 
91
 
Return the specified rightmost number of characters
92
 
 
93
 
RPAD()
94
 
------
95
 
 
96
 
Append string the specified number of times
97
 
 
98
 
SOUNDEX()
99
 
---------
100
 
 
101
 
Return a soundex string
102
 
 
103
 
 
104
 
SUBSTRING()
105
 
-----------
106
 
 
107
 
Returns the substring as specified
108
 
 
109
 
Examples that use SUBSTRING() in the SELECT clause:
110
 
 
111
 
The SUBSTRING() function is used to extract a character string (using a given starting position and a given length). ::
112
 
 
113
 
        SELECT  
114
 
        SUBSTRING(course_designater,6,3) as 'Course number'                   
115
 
        FROM Courses
116
 
        WHERE course_designater LIKE 'Excel%' 
117
 
        LIMIT 10;    
118
 
 
119
 
You can also format a column using SUBSTRING() in combination with functions like LOWER() and UPPER(). ::
120
 
 
121
 
        SELECT 
122
 
        CONCAT(UPPER(SUBSTRING(lastname,1,1)),
123
 
        LOWER(SUBSTRING(lastname,2,29)))
124
 
        FROM Students
125
 
        LIMIT 10;
126
 
 
127