Syntax
LOCATE(substr,str)
LOCATE(substr,str,pos)
Purpose
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 at position pos. If substr is not found in str, the value returned 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
