MariaDB LOCATE関数で特定の文字列が最初に出現する位置を調べる

環境
MariaDB 10.6.4
Windows 10 Home 64bit

構文
LOCATE( 検索する文字列,文字列 )
LOCATE( )関数を使って文字列が最初に見つかった位置を返します

使用例
SQL構文

SELECT LOCATE( 'm' ,'arkgame'),LOCATE( 'm' ,'arkgamearkgame'),LOCATE( 'me' ,'arkgamearkgame')

実行結果

MariaDB [(none)]> SELECT LOCATE( 'm' ,'arkgame'),LOCATE( 'm' ,'arkgamearkgame'),LOCATE( 'me' ,'arkgamearkgame');
+-------------------------+--------------------------------+---------------------------------+
| LOCATE( 'm' ,'arkgame') | LOCATE( 'm' ,'arkgamearkgame') | LOCATE( 'me' ,'arkgamearkgame') |
+-------------------------+--------------------------------+---------------------------------+
|                       6 |                              6 |                               6 |
+-------------------------+--------------------------------+---------------------------------+
1 row in set (0.000 sec)

 

MariaDB

Posted by arkgame