mysql同时替换两个以上字符_MySQL可以替换多个字符吗?

时间:2025-03-11 12:18:41

您可以链接REPLACE函数:

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

这将打印高地。

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

select replace(london_english,'hello','hi') as warwickshire_english

from (

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'

) orig

inner join (

select 'hello' as oldword, 'hi' as newword

union all

select 'world', 'earth'

) trans on =

我将使用通用表表达式作为读者的练习离开翻译;