Purpose
POSITION() searches a string for a specified substring and returns the character position of the first occurrence of the substring.
Syntax
POSITION(substring IN string)
Parameters
Parameter |
Description |
|---|---|
| substring | The substring to search for. |
| string | The string to search. |
Return type
The return type is NUMBER. If the specified substring is not found, the function returns 0.
Examples
The following example returns the character position of the first occurrence of Base in OceanBase:
obclient> SELECT POSITION('Base' IN 'OceanBase') AS result FROM DUAL;
+--------+
| RESULT |
+--------+
| 6 |
+--------+
1 row in set