Mysql LOCATE
From w3cyberlearnings
Contents |
MySQL LOCATE Function
This function returns the first occurrence of substring in string. INSTR() function is similar to Locate() but it has the reverse argument.
Syntax LOCATE
LOCATE(substring, Str, position);
Note
This function is multi-byte safe, and is case-sensitive only if at least one argument is a binary string.
Example 1
mysql> SELECT LOCATE('oo','good'); +---------------------+ | LOCATE('oo','good') | +---------------------+ | 2 | +---------------------+ 1 row in set (0.00 sec)
Example 2
mysql> SELECT LOCATE('is','he is a great and he is lovely',2); +-------------------------------------------------+ | LOCATE('is','he is a great and he is lovely',2) | +-------------------------------------------------+ | 4 | +-------------------------------------------------+ 1 row in set (0.00 sec)