Home  >  Article  >  Database  >  How to manage the starting position of the search in the MySQL LOCATE() function?

How to manage the starting position of the search in the MySQL LOCATE() function?

WBOY
WBOYforward
2023-09-16 09:25:021319browse

如何管理 MySQL LOCATE() 函数中搜索的起始位置?

We know that by default, the search in the LOCATE() function starts from the beginning. We can manage the starting position by giving a parameter to specify the position in the string where we want to start the search. The following example will demonstrate it -

Example

mysql> Select LOCATE('good','Ram is a good boy. Is Ram a good boy?',11)As Result;

+--------+
| Result |
+--------+
|     29 |
+--------+

1 row in set (0.00 sec)

In the above example, we have given the value 11 as the positional parameter. This means that MySQL will start searching from the 11th position.

The above is the detailed content of How to manage the starting position of the search in the MySQL LOCATE() function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete