Mega Code Archive

 
Categories / MySQL Tutorial / String Functions
 

LOCATE(substr,str,pos)

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>