MySQL可以替换多个字符吗?

MySQL可以替换多个字符吗?,第1张

MySQL可以替换多个字符吗?

您可以链接REPLACe函数:

select replace(replace('hello world','world','earth'),'hello','hi')

这将打印

hi earth

您甚至可以使用子查询来替换多个字符串

select replace(london_english,'hello','hi') as warwickshire_englishfrom (    select replace('hello world','world','earth') as london_english) sub

或使用JOIN替换它们:

select group_concat(newword separator ' ')from (    select 'hello' as oldword    union all    select 'world') originner join (    select 'hello' as oldword, 'hi' as newword    union all    select 'world', 'earth') trans on orig.oldword = trans.oldword

我将使用常见的表表达式来进行翻译,作为读者的练习;)



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5018127.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-15

发表评论

登录后才能评论

评论列表(0条)

保存