首页 > 解决方案 > 如何在Oracle中将`(Ab56.12345)some_string`的一列字符串拆分为两列`Ab.12345`,`some_string`并加入原始表?

问题描述

作为问题,

如何将一列字符串拆分(Ab56.12345)some_string为两列Ab56.12345some_string在Oracle中?

注意:不是所有的列都是(Ab56.12345)some_string,部分列只有some_string没有(Ab56.12345),两列是nullsome string

如何查询以下SQL中的所有记录?我只能查询一条记录,但如果所有记录,那是愚蠢的 SQL,我可以在下表中有一idt1吗?

SELECT DISTINCT * FROM
(with test (col) as
(select test_name from test_table WHERE id = '111222')
select REGEXP_SUBSTR(col, '\((.+?)\)', 1, 1, NULL, 1) code,
REGEXP_REPLACE(col, '\(.+?\)', '') name,
col
from test) t1, test_table t2 WHERE t2.id = '111222' and t1.COL=t2.test_name

标签: sqloracle

解决方案


推荐阅读