在 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