我有以下有效的查询,它给出了与我在 where 子句中给出的键相对应的第 n 个字符串作为名称(分隔符是 ##)
select names from (
select
regexp_substr('a##b##c##d##e##f','[^##]+', 1, level) as names,
rownum as nth
from dual
connect by regexp_substr('a##b##c##d##e##f', '[^##]+', 1, level) is not null
)
where nth in (
select nth from (
select
regexp_substr('150##200##13##8##51##61','[^##]+', 1, level) as names,
rownum as nth
from dual
connect by regexp_substr('150##200##13##8##51##61', '[^##]+', 1, level) is not null
)
where names = '200'
)
现在,我有一个表 temp,其中 x 有 3 列 x、y 和 z,其中 x 有类似 a##b##c##d##e##f 的字符串,y 有 1##2##3##4##5## 6 和 z 的数字类似于 1。
如果我有像这样的行
- a##b##c##d##e##f 150##200##13##8##51##61 200
- a##b##c##d##e##f 1##2##3##4##5##6 2
- g##h##i##j##k##l 1##2##3##4##5##99 99
我想要像这样的输出
- a##b##c##d##e##f 150##200##13##8##51##61 200 b
- a##b##c##d##e##f 1##2##3##4##5##6 2 b
- g##h##i##j##k##l 1##2##3##4##5##99 99 l
在上述查询中简单地插入“temp”代替 dual 需要很长时间,因为 db 有超过 50k 行。任何更好的解决方案或如何解决这个问题?