Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2023-09-16 09:25:02
forward
1318 people have browsed it

如何管理 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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!