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

PHPz
Release: 2023-08-21 23:05:04
forward
787 people have browsed it

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)
Copy after login

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)
Copy after login

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!

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
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!