在 MySQL 中,我们使用哪个函数可以从字符串列表中找到某个特定字符串的索引位置?
我们可以使用 FIELD() 函数来从字符串列表中查找某个特定字符串的索引位置。
语法
FIELD(str search,String1, String2,…StringN)
在此处,str search 是我们想要查找其索引号的字符串,而 String1、String …StringN 是从中进行查找的字符串列表。
示例
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)
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程语言
C++
C#
MongoDB
MySQL
JavaScript
PHP