~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Andrew Hutchings
  • Date: 2011-02-23 13:08:09 UTC
  • mto: (2196.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2197.
  • Revision ID: andrew@linuxjedi.co.uk-20110223130809-mbd2rypxod2tfre6
Fix SQL markup

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
FIELD
5
5
-----
6
6
 
7
 
The FIELD function returns the index (position) of string arguments (str1, str2, str3, ….) 
 
7
The FIELD function returns the index (position) of string arguments (str1, str2, str3, ...) 
8
8
 
9
9
It returns 0 if the str value is not found.
10
10
 
12
12
 
13
13
Otherwise, the arguments are compared as double.
14
14
 
15
 
If str is NULL, the return value is 0 because NULL fails equality comparison with any value. FIELD() is the complement of ELT(). ::
 
15
If str is NULL, the return value is 0 because NULL fails equality comparison with any value. FIELD() is the complement of ELT().
 
16
 
 
17
.. code-block:: mysql
16
18
 
17
19
        SELECT FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo');
18
20
 
19
 
Returns 2 ::
 
21
Returns 2
 
22
 
 
23
.. code-block:: mysql
20
24
        
21
25
        SELECT FIELD('fo', 'Hej', 'ej', 'Heja', 'hej', 'foo');
22
26
 
30
34
INSTR
31
35
-----
32
36
 
33
 
INSTR(str, substr) returns the index of the first occurrence of substring str in string substr. Note that this works like LOCATE except the order of the arguments is reversed: ::
 
37
INSTR(str, substr) returns the index of the first occurrence of substring str in string substr. Note that this works like LOCATE except the order of the arguments is reversed:
 
38
 
 
39
.. code-block:: mysql
34
40
 
35
41
        SELECT INSTR('tacosalad', 'salad');
36
42
                -> 4