1. Use a
LOCATE (SUBSTR,STR)
POSITION (substr in str)
The function returns the position of the substring substr the first occurrence in the string str. 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 case insensitive. In MySQL3.23, this function is case-sensitive, and when in MySQL4.0, if any of the arguments are a binary string, it is case-sensitive.
2. Usage two
LOCATE (Substr,str,pos)
The function returns the position of the substring substr the first occurrence after the POS position in the string str. If SUBSTR does not return 0 in Str.
mysql> SELECT LOCATE (' Bar ', ' Foobarbar ', 5);
7
This function is case insensitive. In MySQL 3.23, this function is case-sensitive, and when in MySQL 4.0, if either parameter is a binary string, it is case-sensitive.
3. Example
SELECT * from Tb_name WHERE LOCATE(colum1,colum1,1) >0
Function: string matching function in MySQL locate and position use method