MySQL INSERT() 函式
示例
在字串 "W3Schools.com" 中插入字串 "Example",替換前九個字元。
SELECT INSERT("W3Schools.com", 1, 9, "Example");
自己動手試一試 »
定義和用法
INSERT() 函式在指定位置插入一個字串,並替換指定數量的字元。
語法
INSERT(string, position, number, string2)
引數值
引數 | 描述 |
---|---|
string | 必需。將被修改的字串 |
position | 必需。插入 string2 的位置 |
數字 | 必需。要替換的字元數 |
string2 | 必需。要插入到 string 中的字串 |
返回值
- 如果 position 超出 string 的長度,則此函式返回 string。
- 如果 number 大於 string 中剩餘部分的長度,則此函式從 position 開始,將 string 替換直到字串末尾。
技術詳情
支援版本 | 從 MySQL 4.0 開始 |
---|
更多示例
示例
在字串 "W3Schools.com" 中插入字串 "no",從位置 11 開始替換三個字元。
SELECT INSERT("W3Schools.com", 11, 3, "no");
自己動手試一試 »