开发者

Replacing characters with specified one

I have a string as follows - MFMFMF

now i want to change this string to FMFMFM how to do this , help needed pls

i had tried

select replace(replace('mfmfmf','M','F'),'F','M') this gives 开发者_StackOverflow社区me result - MMMMMM which i donot what i want the output to be FMFMFM Need your help

D.Mahesh


Try:

select replace(replace(replace('mfmfmf', 'm', 'x'), 'f', 'm'), 'x', 'f') ...

It's because your first replace yields:

ffffff

And then replacing fs with ms, yields mmmmmm. You need an intermediary replace.


select replace(replace(replace('mfmfmf','M','X'),'F','M'),'X','F')

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜