【问题标题】:Oracle SQL statement to select string between '\' and '#'Oracle SQL 语句在 '\' 和 '#' 之间选择字符串
【发布时间】:2018-05-01 23:15:49
【问题描述】:

我在 Oracle 11g 数据库中有一个表,其中包含一个名为 REPORT 的列。我正在尝试编写一个在下面显示所需结果的选择语句。我需要选择“\”和随后出现的“#”之间的字符串。我认为这可以使用 regexp_substr 函数来完成,但我没有取得任何成功。我有太多上周尝试失败的例子,无法在此处发布。任何帮助将不胜感激。

REPORT_COLUMN

#Med Reports\Client, Ray.dco#
Financial Reports\Client, Justin-1.dco#Financial Reports/Client, Justin-1.dco#
#Med Reports\Client, Jessy.dco#
Financial Reports\Client, Channa-1.dco#Financial Reports/Client, Charnisha-1.dco#

要求的结果:

Client, Ray.dco
Client, Justin-1.dco
Client, Jessy.dco
Client, Channa-1.dco

【问题讨论】:

    标签: sql oracle plsql regexp-substr


    【解决方案1】:
    select regexp_substr(REPORT_COLUMN,'\\(.*?)#',1,1,'',1)
      from Table
    

    【讨论】:

    • 谢谢。这完美无缺。我承认我还没有完全理解它。我想我需要研究一下 regexp_substr。
    猜你喜欢
    • 2015-06-21
    • 1970-01-01
    • 1970-01-01
    • 2019-05-12
    • 2011-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-03
    相关资源
    最近更新 更多