INSTR
Descriptionβ
Returns the first occurrence position of substr in str (counting starts from 1). Special cases:
- If substr does not appear in str, returns 0.
Syntaxβ
INSTR ( <str> , <substr> )
Parametersβ
Parameter | Description |
---|---|
<str> | String to search for |
<substr> | String to be searched for |
Return valueβ
Parameters The first occurrence position of <substr>
in <str>
(counting starts from 1). Special cases:
- If
<substr>
does not appear in<str>
, returns 0.
Exampleβ
SELECT INSTR("abc", "b"),INSTR("abc", "d")
+-------------------+-------------------+
| instr('abc', 'b') | instr('abc', 'd') |
+-------------------+-------------------+
| 2 | 0 |
+-------------------+-------------------+