Syntax
LOCATE(substr,str)
LOCATE(substr,str,pos)
Purpose
The first syntax returns the position of the first occurrence of substr of str. The second syntax returns the position of the first occurrence of substr in str, with pos as the start position. If substr is not in str, 0 is returned.
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