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