Posts

Split comma separated values into rows Oracle database

Most often we receive comma separated text data that we need to convert to rows.  To do this with SQL we can use several method. Method : 1 >> Using SQL Query select regexp_substr(   ltrim(rtrim(REGEXP_REPLACE(REPLACE('382,   Al-amin Road,South Paikpara, Kollaynpur, Mirpur,Dhaka',',',', ') , ' {2,}', ' '))), '[^,]+', 1, level) My_Add_Line from dual  connect BY regexp_substr(   ltrim(rtrim(REGEXP_REPLACE(REPLACE('382,   Al-amin Road,South Paikpara, Kollaynpur, Mirpur,Dhaka',',',', ') , ' {2,}', ' '))), '[^,]+', 1, level)   is not null;      Method: 2 >>  Using a WITH clause   with add_tab as (   select  ltrim(rtrim(REGEXP_REPLACE(REPLACE('345,   Al-amin Road,South Paikpara, Kollaynpur, Mirpur,Dhaka',',',', ') , ' {2,}', ' '))) my_str from dual )   select ltrim(rtrim(regexp_substr (             my_str,            '[^,]+',            1
Recent posts