如何在字符预言后获取字符串 [英] How to get string after character oracle

查看:79
本文介绍了如何在字符预言后获取字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有VP3 - Art & Design and HS5 - Health & Social Care,在Oracle中,我需要在'-'之后获取字符串.可以使用子字符串来实现吗?

I have VP3 - Art & Design and HS5 - Health & Social Care, I need to get string after '-' in Oracle. Can this be achieved using substring?

推荐答案

对于这样简单的字符串操作,我可能只使用基本的INSTR()SUBSTR()函数.在下面的查询中,我们从连字符 之后的两个位置处获取您列的子字符串.

For a string operation as simple as this, I might just use the base INSTR() and SUBSTR() functions. In the query below, we take the substring of your column beginning at two positions after the hyphen.

SELECT
    SUBSTR(col, INSTR(col, '-') + 2) AS subject
FROM yourTable

我们也可以在此处使用REGEXP_SUBSTR()(请参阅Gordon的答案),但这会稍微复杂一些,并且性能可能不如上面的查询.

We could also use REGEXP_SUBSTR() here (see Gordon's answer), but it would be a bit more complex and the performance might not be as good as the above query.

这篇关于如何在字符预言后获取字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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