LOCATE(substr,str): Returns the position of the first occurrence of substring substr in string str : LOCATE « String Functions « MySQL Tutorial






Returns 0 if substr is not in str.

mysql>
mysql> SELECT LOCATE('ABC', 'ABCABC');
+-------------------------+
| LOCATE('ABC', 'ABCABC') |
+-------------------------+
|                       1 |
+-------------------------+
1 row in set (0.00 sec)

mysql>
mysql> SELECT LOCATE('AA', 'AABBCCDD');
+--------------------------+
| LOCATE('AA', 'AABBCCDD') |
+--------------------------+
|                        1 |
+--------------------------+
1 row in set (0.00 sec)








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)