欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

对账单月字段按逗号分隔形成多条数据

程序员文章站 2022-10-18 10:28:23
''' SELECT a.id, substring_index(substring_index(a.bill_ids, ',', b.id), ',', 1) bill_ids, a.status, a.card_name FROM (SELECT id, bill_ids,status,card ......

'''
select a.id,
substring_index(substring_index(a.bill_ids, ',', b.id), ',', -1) bill_ids,
a.status,
a.card_name
from (select id, bill_ids,status,card_name
from af_repayment
where bill_ids<>' ') a
join af_activity_model b on b.id <= (length(a.bill_ids) - length(replace(a.bill_ids, ',', ''))+1)
order by a.id
'''