📜  sqlite 选择拆分字符串 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:25.391000             🧑  作者: Mango

代码示例1
-- using your data table assuming that b3 is suppose to be b2

WITH split(one, many, str) AS (
    SELECT one, '', many||',' FROM data
    UNION ALL SELECT one,
    substr(str, 0, instr(str, ',')),
    substr(str, instr(str, ',')+1)
    FROM split WHERE str !=''
) SELECT one, many FROM split WHERE many!='' ORDER BY one;

a|a1
a|a2
a|a3
b|b1
b|b2
c|c2
c|c1