I have the below query which works, which gives the nth string corresponding to the key I give in the where clause as names (separator being ##)
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'
)
Now, I have a table temp with say 3 columns x,y and z where x has strings like a##b##c##d##e##f, y has 1##2##3##4##5##6 and z will have number like 1.
If I have a rows like
- 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
I want outputs like
- 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
simply plugging "temp" in place of dual in the above query takes long time as the db has over 50k rows. Any better solution or how do I fix this?