在MySQL中,我们可以使用哪个函数从字符串列表中查找特定字符串的索引位置

2023年12月7日07:58:18

我们可以使用FIELD()函数从字符串列表中查找特定字符串的索引位置。

语法

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

在这里,str搜索是我们要搜索其索引号的字符串,而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)

  • 更新时间:2023年12月7日07:58:18 ,共 372 字。