INSERT

创建于 2024-12-02 / 38
字体: [默认] [大] [更大]

❮ MySQL 函数

实例

将字符串 "Example" 插入字符串 "www.w3ccoo.com"。 替换前九个字符:

SELECT INSERT("www.w3ccoo.com", 1, 9, "Example"); 亲自试一试 »

定义和用法

INSERT() 函数在字符串中的指定位置插入一个字符串,并插入一定数量的字符。

语法

INSERT(string, position, number, string2)

参数值

参数 描述
string 必需。将要修改的字符串
position 必需。插入 string2 的位置
number 必需。要替换的字符数
string2 必需。要插入 string 的字符串

返回值

  • 如果position 超出string的长度,这个函数返回string
  • 如果 number 大于 string 其余部分的长度,此函数将 string 替换为 position 直到 string
  • 结束

技术细节

适用于: From MySQL 4.0

更多实例

实例

将字符串"no"插入字符串"www.w3ccoo.com"。 替换三个字符,从位置 11 开始:

SELECT INSERT("www.w3ccoo.com", 11, 3, "no"); 亲自试一试 »

❮ MySQL 函数


0 人点赞过