本文介绍了如何替换MYSQL中最后出现的子字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
String: / strong>American Corp National Corp
搜索字符串:Corp
预期输出:美国公司国民
任何人都可以建议?
解决方案
尝试:
'American Corp National Corp'),
instr(reverse('American Corp National Corp'),reverse('Corp')) - 1),
substr ,
instr(reverse('American Corp National Corp'),reverse('Corp'))+
length('Corp'))))result
( SQLFiddle )
How can I replace the last occurrence of a substring with blank string in MYSQL?I could not find any such direct function in MYSQL
String: "American Corp National Corp"
Search String: "Corp"
Expected output: "American Corp National"
Could anyone suggest?
解决方案
Try:
select reverse(concat(
left(reverse('American Corp National Corp'),
instr(reverse('American Corp National Corp'),reverse('Corp'))-1),
substr(reverse('American Corp National Corp'),
instr(reverse('American Corp National Corp'),reverse('Corp'))+
length('Corp')))) result
这篇关于如何替换MYSQL中最后出现的子字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!