在 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)
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP