我有一个类似的表:提取某些字符串,并将其分配给相邻列
with tab as(
select 'P710345,P345123 are not valid' m from dual
union all
select 'P9,P234098,P675001 are not valid' m from dual)
select * from tab
我需要的是提取与P
开头的字符串,并将这些字符串放到新列在同一排。
最终结果:
P710345,P345123 are not valid | P710345 | P345123 | |
P9,P234098,P675001 are not valid | P9| P234098 |P675001 |
我试图与regexp_substr
提取:
with tab as(
select 'P710345,P345123 are not valid' m from dual
union all
select 'P9,P234098,P675001 are not valid' m from dual)
select regexp_substr (m,'P\d\w+','2') b from tab
我目前在这里停留。
存储多个值是坏的数据库设计,最好的办法是改变设计,但如果它不可能,我会看看我是否可以写一些SQL来帮助 –
谢谢。数据库设计是目前给出的。因为它不是生产数据库,所以我认为目前它是可以接受的。 – bonsvr