跳转到内容

返回将字符串 str 中所有出现的字符串 from_str 替换为字符串 to_str 后的字符串。

func.replace(<str>, <from_str>, <to_str>)
func.replace(<str>, <from_str>, <to_str>)
┌──────────────────────────────────────┐
│ func.replace('plaidCloud', 'p', 'P') │
├──────────────────────────────────────┤
│ PlaidCloud │
└──────────────────────────────────────┘
REPLACE(<str>, <from_str>, <to_str>)
参数 说明
<str> 字符串。
<from_str> 源字符串。
<to_str> 目标字符串。

VARCHAR

SELECT REPLACE('www.mysql.com', 'w', 'Ww');
┌─────────────────────────────────────┐
│ REPLACE('www.mysql.com', 'w', 'Ww') │
├─────────────────────────────────────┤
│ WwWwWw.mysql.com │
└─────────────────────────────────────┘