Syntax
LOCATE(substr,str)
LOCATE(substr,str,pos)
Purpose
You can use the first syntax to return the position of the first occurrence of substr in str. You can use the second syntax to return 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 (0.00 sec)