Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql MS SQL查询以删除前缀_Mysql_Sql_String_Xcode_Str Replace - Fatal编程技术网

Mysql MS SQL查询以删除前缀

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

我有下面的like列值,希望排除字符和连字符,只返回数字。replace函数并非完全有用,因为有时字符长度为3,有时字符长度为4,请参见下文,因为数字长度也会发生变化

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]+$')