I have multi-line text data stored in table rows like this mock example here. Some of the rows are flagged as "IMPORTANT" and I'm trying to select a list of all the "IMPORTANT" rows along with corresponding IDs.
select 10001 as id, 'some random text 11
more random text IMPORTANT 12
more random text IMPORTANT 13' as str
from dual
union all
select 10002, 'other random text 21
other random text IMPORTANT 22
other random text 23'
from dual;
I need something like this...
id important text
10001 more random text IMPORTANT 12
10001 more random text IMPORTANT 13
10002 other random text IMPORTANT 22
I'd like this in a single SELECT, without any temp tables or cursors, and I've been looking at regexp_substr with connect by queries, but I seem to be stuck. Your help would be appreciated.