本帖最后由 天之云 于 2023-4-18 12:13 编辑
拿去:
按照你的要求,这个只针对sqlite数据库
新建表测试
- WITH split ( id, splid, idsstr ) AS (
- SELECT
- id,
- '',
- ids || ','
- FROM
- test UNION ALL
- SELECT
- id,
- substr( idsstr, 0, instr ( idsstr, ',' ) ),
- substr( idsstr, instr ( idsstr, ',' ) + 1 )
- FROM
- split
- WHERE
- idsstr != ''
- ) SELECT
- id,
- splid
- FROM
- split
- WHERE
- splid != ''
- ORDER BY
- id;
复制代码
|