How can I manage the start position of searching in MySQL LOCATE() function?

MySQLMySQLi Database

As we know that by default searching in LOCATE() function starts from beginning. We can manage the start position by giving an argument to specify the position from which we want to start the search in string. 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 argument for position. It means that MySQL will start searching from 11th position.

raja
Published on 20-Feb-2018 11:38:08
Advertisements