Declaration
LOCATE(substr,str)
LOCATE(substr,str,pos)
Description
The first syntax returns the first occurrence of the substring substr in the string str. The second syntax returns the first occurrence of the substring substr in the string str, starting from position pos. If substr is not found in str, the return value is 0.
Examples
obclient> SELECT LOCATE('bar', 'foobarbar'), LOCATE('xbar', 'foobar'), LOCATE('bar', 'foobarbar',5);
+----------------------------+--------------------------+------------------------------+
| LOCATE('bar', 'foobarbar') | LOCATE('xbar', 'foobar') | LOCATE('bar', 'foobarbar',5) |
+----------------------------+--------------------------+------------------------------+
| 4 | 0 | 7 |
+----------------------------+--------------------------+------------------------------+
1 row in set