从 MySQL 中的第一个整数查找/剪切字符串 [英] Find/Cut string from first integer in MySQL

查看:42
本文介绍了从 MySQL 中的第一个整数查找/剪切字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,在我的数据库中我有这样的值:

I'm stuck with a problem, in my database i've values like this:

GSB45-B,GSBD60-01,等

GSB45-B, GSBD60-01, etc.

现在我需要从这些字符串中获取值 GSB/GSBD.所以实际上我需要从 te start 到第一个整数的第一个字符.

Now i need to get the values GSB / GSBD out of these strings. So in fact i need te first character from te start to the first integer.

希望有人能帮助我,谢谢.

Hopefully someone can help me, thanks from now.

推荐答案

这有点笨拙的解决方案,但您可以尝试:

It's a bit of a clunky solution, but you can try:

SELECT 
    REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING_INDEX(column, '-', 1), '0', ''), '1', ''), '2', ''), '3', ''), '4', ''), '5', ''), '6', ''), '7', ''), '8', ''), '9', '') AS extracted
FROM
    yourtbl

这篇关于从 MySQL 中的第一个整数查找/剪切字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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