跳到主要内容
跳到主要内容

OVERLAY

overlay

Description

Syntax

VARCHAR Overlay (VARCHAR str, INT pos, INT len, VARCHAR newstr)

返回字符串 str,并用字符串 newstr 替换从位置 pos 开始、长度为 len 字符的子字符串。如果 pos 不在字符串长度范围内,则返回原始字符串。如果 len 不在字符串其余部分的长度范围内,则从位置 pos 开始替换字符串其余部分。如果任何参数为 NULL,则返回 NULL。

example

mysql> select overlay('Quadratic', 3, 4, 'What');
+------------------------------------+
| overlay('Quadratic', 3, 4, 'What') |
+------------------------------------+
| QuWhattic |
+------------------------------------+
mysql> select overlay('Quadratic', -1, 4, 'What');
+-------------------------------------+
| overlay('Quadratic', -1, 4, 'What') |
+-------------------------------------+
| Quadratic |
+-------------------------------------+
mysql> select overlay('Quadratic', 3, 100, 'What');
+--------------------------------------+
| overlay('Quadratic', 3, 100, 'What') |
+--------------------------------------+
| QuWhat |
+--------------------------------------+
mysql> select overlay('Quadratic', 3, -1, 'What');
+-------------------------------------+
| overlay('Quadratic', 3, -1, 'What') |
+-------------------------------------+
| QuWhat |
+-------------------------------------+
mysql> select overlay('Quadratic', 0, 100, 'What');
+--------------------------------------+
| overlay('Quadratic', 0, 100, 'What') |
+--------------------------------------+
| Quadratic |
+--------------------------------------+

keywords

OVERLAY