Mysql MS SQL查询以删除前缀
我有下面的like列值,希望排除字符和连字符,只返回数字。replace函数并非完全有用,因为有时字符长度为3,有时字符长度为4,请参见下文,因为数字长度也会发生变化Mysql MS SQL查询以删除前缀,mysql,sql,string,xcode,str-replace,Mysql,Sql,String,Xcode,Str Replace,我有下面的like列值,希望排除字符和连字符,只返回数字。replace函数并非完全有用,因为有时字符长度为3,有时字符长度为4,请参见下文,因为数字长度也会发生变化 abc-1234567 sdfr-9876540 try-12345678 case-098765 如果要在最后一个连字符之后添加零件,可以使用子字符串\u index(): 您还可以使用regexp\u substr()提取末尾的数字: 标题是ms sql,但您标记的问题是mysql。你用哪一种? select substri
abc-1234567
sdfr-9876540
try-12345678
case-098765
如果要在最后一个连字符之后添加零件,可以使用
子字符串\u index()
:
您还可以使用regexp\u substr()
提取末尾的数字:
标题是ms sql,但您标记的问题是mysql。你用哪一种?
select substring_index(col, '-', -1)
select regexp_substr(col, '[0-9]+$')