Home  >  Article  >  Database  >  In MySQL, which function can we use to find the index position of a specific string from a list of strings?

In MySQL, which function can we use to find the index position of a specific string from a list of strings?

PHPz
PHPzforward
2023-08-21 23:05:04851browse

In MySQL, which function can we use to find the index position of a specific string from a list of strings?

We can use the FIELD() function to find the index position of a specific string from a list of strings.

Syntax

FIELD(str search,String1, String2,…StringN)

Here, str search is the index number of the string we want to search, and String1, String...StringN are the list of strings where the search will occur.

Example

mysql> Select FIELD('good', 'Ram', 'is', 'a', 'good', 'boy')AS 'Index Number of good';
+----------------------+
| Index Number of good |
+----------------------+
|                  4   |
+----------------------+
1 row in set (0.00 sec)

The above is the detailed content of In MySQL, which function can we use to find the index position of a specific string from a list of strings?. 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