LOCATE function
parameter:
substr - - string to query
str - - field name
pos - - Starting to Find
return value:
Returns the position of substr in str where it first appears, did not return 0
PS: When MySQL 4.0 when, if one of the parameters is a binary string, it is case-sensitive letters
grammar:
LOCATE(substr,str)
SELECT LOCATE ( 'bar', 'foobarbar'); // Result: 4
SELECT LOCATE ( 'xbar', 'foobar'); // Results: 0
LOCATE(substr,str,pos)
Returns the string str substr the first position of the substring appears from the starting position pos. 0 if substr is not, str is returned. Substr or returns NULL if str is NULL.
Note: pos must be greater than the position of the first occurrence in order to show the position of the second occurrence of
SELECT LOCATE ( 'bar', 'foobarbar', 5); // Result: 7
When the position of the position (5) less occurrence of the first time, or returns the first occurrence
POSITION()
parameter:
substr - - string to query
str - - field name
return value:
Returns a string to query the position of the first occurrence is in the query string (just like in and locate, check a lot of information position is locate alias)
Substr Returns the string str appears at a position, no return 0
usage:
POSITION(substr IN str)
SELECT POSITION ( 'cn' IN 'aaaaacn'); // Result: 6
INSTR()
Returns: Wuxi abortion costs http://www.xasgfk120.com/
Returns the position of the first string to appear in the query is the query string. This is the LOCATE () in the two-parameter form of the same, but the order parameter is reversed.
grammar:
INSTR(str,substr)
Substr Returns the string str appears at a position, no return 0
SELECT INSTR ( 'aaaacom', 'com'); // Result: 5
FIND_IN_SET()
Returns the index in the set position (vertical development)
grammar:
FIND_IN_SET(str,strlist)
Returns the index position in str1 set strlist
SELECT FIND_IN_SET('demo.com.cn',t.str) FROM `table` t;
IN()
return value:
Returns the index position in the collection (with the FIND_IN_SET)
grammar:
str IN (strlist)
Returns the index position in str1 set strlist
SELECT 'demo.com.cn' IN(t.str) FROM `table` t;
LIKE
Return similar (fuzzy) set of characters
LIKE %str%
Returns str similar collection