使用mysql查询获取字符串的最后5个字符 [英] Getting last 5 char of string with mysql query

查看:1483
本文介绍了使用mysql查询获取字符串的最后5个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用mysql获取最后5个数字.

I have to get last 5 numbers using mysql.

我的值就像YOT-A78514LOP-C4521 ...

My values are like YOT-A78514,LOP-C4521 ...

我只能得到最后五个字符.如何在查询中做到这一点?

I have to get only last five char . How can I do this in query?

推荐答案

您可以使用

You can do this with RIGHT(str,len) function. Returns the rightmost len characters from the string str,

像下面这样:

SELECT RIGHT(columnname,5) as yourvalue FROM tablename

这篇关于使用mysql查询获取字符串的最后5个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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