~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Lee Bieber
  • Date: 2011-02-23 05:05:43 UTC
  • mfrom: (2193.1.2 build)
  • Revision ID: kalebral@gmail.com-20110223050543-w0nhgf512s0137mm
Merge Andrew - 723389: ORDER BY on sys_replication_log table causes InnoDB crash
Merge Marisa - documentation updates

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
INSTR
31
31
-----
32
32
 
33
 
Return the index of the first occurrence of substring
 
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: ::
 
34
 
 
35
        SELECT INSTR('tacosalad', 'salad');
 
36
                -> 4
 
37
        SELECT INSTR('burger', 'salad');
 
38
                -> 0
34
39
 
35
40
LEFT
36
41
----
40
45
INSERT
41
46
------
42
47
 
43
 
Insert a substring at the specified position up to the specified number of characters
 
48
This function inserts a substring at the specified position up to the specified number of characters.
 
49
 
 
50
INSERT(str,pos,len,newstr)
 
51
 
 
52
It returns str (a string), with the substring beginning at pos (position) and len (how many characters long) replaced by the newstr. 
 
53
 
 
54
* INSERT returns the original string if pos is not within the length of the string
 
55
* It replaces the rest of the string from position pos if len is not within the length of the rest of the string
 
56
* It returns NULL if any argument is NULL
 
57
 
 
58
.. code-block:: mysql
 
59
 
 
60
        SELECT INSERT('Aquatic', 3, 2, 'Me');
 
61
                -> 'AqMetic'
 
62
        SELECT INSERT('Aquatic', -1, 4, 'This');
 
63
                -> 'Aquatic'
 
64
        SELECT INSERT('Aquatic', 3, 100, 'This');
 
65
                -> 'AqThis'
 
66
 
44
67
 
45
68
LOCATE
46
69
------
47
70
 
48
 
Return the position of the first occurrence of substring
 
71
Return the position of the first occurrence of substring.
49
72
 
50
73
POSITION
51
74
--------