MySQL-LOCATE () function
The definition of a
Returns the string str substr position of the first occurrence of the substring
grammar
LOCATE(substr,str)
Definition of two
Returns the string str substr the first position of the substring appears from the starting position pos
grammar
LOCATE(substr,str,pos)
parameter
parameter | description |
---|---|
substr | It must contain values |
str | You must look for strings |
pos | Optionally, starting at position pos |
example
mysql> SELECT LOCATE('bar', 'foobarbar');
-> 4
mysql> SELECT LOCATE('xbar', 'foobar');
-> 0
mysql> SELECT LOCATE('bar', 'foobarbar', 5);
-> 7