I have a Table called Test with below values
ID Name Description
1 Xyz Mumbai,Delhi
I want Sql query which will give output as below
ID Name Description
1 Xyz Mumbai
1 Xyz Delhi
I have a Table called Test with below values
ID Name Description
1 Xyz Mumbai,Delhi
I want Sql query which will give output as below
ID Name Description
1 Xyz Mumbai
1 Xyz Delhi
You can use regexp_substr
with '[^,]+'
pattern as second argument to split the comma seperated string
with tab( ID, Name, Description ) as
(
select 1,'Xyz','Mumbai,Delhi' from dual
)
select ID, Name,
regexp_substr(Description,'[^,]+',1,level)
as Description
from tab
connect by level <= regexp_count(Description,',')+1;
ID NAME DESCRIPTION
-- ---- -----------
1 Xyz Mumbai
1 Xyz Delhi