LOCATE(substr,str,pos) : LOCATE « String Functions « MySQL Tutorial






Returns the position of the first occurrence of substring substr in string str, starting at position pos.

Returns 0 if substr is not in str.

POSITION(substr IN str) is a synonym for LOCATE(substr,str).

mysql>
mysql> SELECT LOCATE('bar', 'foobarbar', 5);
+-------------------------------+
| LOCATE('bar', 'foobarbar', 5) |
+-------------------------------+
|                             7 |
+-------------------------------+
1 row in set (0.00 sec)

mysql>








23.23.LOCATE
23.23.1.LOCATE(substr,str): Returns the position of the first occurrence of substring substr in string str
23.23.2.LOCATE 'a' letter in the first name
23.23.3.LOCATE(substr,str,pos)