mysql:从右边返回第一次出现的子字符串? (subrstring ?!) [英] mysql: substring that returns the first occurrence from the right? (subrstring?!)

查看:348
本文介绍了mysql:从右边返回第一次出现的子字符串? (subrstring ?!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以从sql中字符串的右侧返回第一次出现的空格?

is there a way to return the first occurrence of a space from the right side of the string in sql?

推荐答案

嗯,简短浏览功能列表并没有弹出任何向后搜索"功能,但是您可以做的是反转字符串并向前搜索:

Hmm, a brief browse through the function list didn't pop up any "search backwards" functions at me, but what you could do is reverse the string and search forwards:

SELECT LENGTH(`haystack`) - POSITION('needle' IN REVERSE(`haystack`))

这篇关于mysql:从右边返回第一次出现的子字符串? (subrstring ?!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆