Splitting Delimited String Into Individual Rows

Problem

You have a delimited string, and you want to separate it out into individual rows

Solution


select regexp_substr('STRING1:STRING2','[^:]+', 1, level) from dual
   connect by regexp_substr('STRING1:STRING2', '[^:]+', 1, level) is not null;

I've highlighted the delimiter, in my case it was a ":".


You wouldn't normally have the values hard-coded, this is just to display the method. You could use this if (for some reason_ you have these value in a table column, or a form field etc.

Acknowledgement

https://blogs.oracle.com/aramamoo/entry/how_to_split_comma_separated_string_and_pass_to_in_clause_of_select_statement


Comments