how to transform comma separated column into multiples rows in db2

前端 未结 4 643
野趣味
野趣味 2020-12-10 20:38

I have the following table (the number of the references is variable):

Id | FK_ID| Reference |
-----------------------
1    2100   GI2, GI32
2    2344   GI56         


        
4条回答
  •  北海茫月
    2020-12-10 21:07

    I posted a generic solution for this type of transform under Split comma separated entries to rows

    To view results for this sample data, replace the session data with:

    INSERT INTO session.sample_data SELECT 1, 2100, 'GI2,GI32' FROM sysibm.sysdummy1;
    INSERT INTO session.sample_data SELECT 2, 2344, 'GI56' FROM sysibm.sysdummy1;
    

    Results:

    ID  OTHERID DATA
    1   2100    GI2
    1   2100    GI32
    2   2344    GI56
    

提交回复
热议问题