LOCATE (substr, str)
POSITION (substr IN str)
Returns the position of the substring substr that appears for the first time in the str string. If the substring substr does not exist in str, the return value is 0:
Mysql> select locate ('bar', 'foobarbar ');
-> 4
Mysql> select locate ('xbar', 'foobar ');
-> 0
This function is multi-byte secure. In MySQL 3.23, this function is case-sensitive. in MySQL 4.0, if any parameter is a binary string, it is case-sensitive.
LOCATE (substr, str, pos)
Returns the position where the substring substr first appears after the position pos in the str string. If substr is not in str, return 0:
Mysql> select locate ('bar', 'foobarbarbar ', 5 );
-> 7
This function is multi-byte secure. In MySQL 3.23, this function is case-sensitive. in MySQL 4.0, if any parameter is a binary string, it is case-sensitive.
A typical example is:
Slect * from tablename where LOCATE (colum1, colum1, 1)> 0