メインコンテンツまでスキップ
バージョン: 4.x

MULTI_SEARCH_ALL_POSITIONS

multi_search_all_positions

説明

構文

ARRAY<INT> multi_search_all_positions(VARCHAR haystack, ARRAY<VARCHAR> needles)

ARRAYを返します。この配列のi番目の要素は、needlesi番目の要素(すなわちneedle)が文字列haystack内で最初に出現する位置です。位置は1から数え、0は要素が見つからなかったことを意味します。大文字小文字を区別します

mysql> select multi_search_all_positions('Hello, World!', ['hello', '!', 'world']);
+----------------------------------------------------------------------+
| multi_search_all_positions('Hello, World!', ['hello', '!', 'world']) |
+----------------------------------------------------------------------+
| [0,13,0] |
+----------------------------------------------------------------------+

select multi_search_all_positions("Hello, World!", ['hello', '!', 'world', 'Hello', 'World']);
+---------------------------------------------------------------------------------------------+
| multi_search_all_positions('Hello, World!', ARRAY('hello', '!', 'world', 'Hello', 'World')) |
+---------------------------------------------------------------------------------------------+
| [0, 13, 0, 1, 8] |
+---------------------------------------------------------------------------------------------+

keywords

MULTI_SEARCH,SEARCH,POSITIONS