SQLite3で文字列を指定した文字列で置換する方法

環境
Windows 10 Home 64bit
SQLite 3.39.2
構文
REPLACE( 文字列, 置換される文字列, 置換する文字列 )
REPLACE関数を使用して文字列を指定した文字列で置換します。

SQL構文

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SELECT
REPLACE('study skill', 's', 'T'),
REPLACE('study skill', 'll', 'MM'),
REPLACE('study skill', 'tu', 'SN')
SELECT REPLACE('study skill', 's', 'T'), REPLACE('study skill', 'll', 'MM'), REPLACE('study skill', 'tu', 'SN')
SELECT
REPLACE('study skill', 's', 'T'),
REPLACE('study skill', 'll', 'MM'),
REPLACE('study skill', 'tu', 'SN')

操作例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sqlite> SELECT
...> REPLACE('study skill', 's', 'T'),
...> REPLACE('study skill', 'll', 'MM'),
...> REPLACE('study skill', 'tu', 'SN');
sqlite> SELECT ...> REPLACE('study skill', 's', 'T'), ...> REPLACE('study skill', 'll', 'MM'), ...> REPLACE('study skill', 'tu', 'SN');
sqlite> SELECT
   ...> REPLACE('study skill', 's', 'T'),
   ...> REPLACE('study skill', 'll', 'MM'),
   ...> REPLACE('study skill', 'tu', 'SN');

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Ttudy Tkill|study skiMM|sSNdy skill
Ttudy Tkill|study skiMM|sSNdy skill
Ttudy Tkill|study skiMM|sSNdy skill

 

SQLite

Posted by arkgame