在 MySQL 中,我们可以使用哪个函数从字符串列表中查找特定字符串的索引位置?
mysqlmysqli database
我们可以使用 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)