If a substring appears multiple times in a string, the MySQL LOCATE() function returns the position of the first occurrence of the substring.
mysql> Select LOCATE('good','Ram is a good boy. Is Ram a good boy?')As Result; +--------+ | Result | +--------+ | 10 | +--------+ 1 row in set (0.00 sec)
We can see that the substring "good" appears twice in the string. The first time appears at position 10 and the other time at position 29. MySQL returns the position of the first occurrence.
The above is the detailed content of What happens if a substring appears multiple times in the string given as an argument to the LOCATE() function?. For more information, please follow other related articles on the PHP Chinese website!