mysql ||

将多条记录的某个字段合并成一条记录

group_concat : 将某字段多条记录合并,默认逗号分隔

select group_concat(c.invoice_no) from ibc_comm_invoice c where c.settle_nos like concat(‘%‘,m.settle_no,‘%‘) 

group_concat(xxx separator ‘符号‘) : 以 "符号"分割

select group_concat(c.invoice_no separator ‘;‘) from ibc_comm_invoice c where c.settle_nos like concat(‘%‘,m.settle_no,‘%‘)

sql

select  m.id,m.settle_no,m.fee_type,m.org_code,m.person_code,m.person_name,m.team_code,
m.agent_code,m.agent_name,m.company_code,m.company_name,m.sum_policy_premium,
m.policy_currency,m.exchange_rate,m.fee_currency,m.sum_fee,m.created_by,m.created_date,
m.updated_by,m.updated_date,m.payment_fee,m.payment_date,m.resultFlag,
(select group_concat(c.invoice_no) from ibc_comm_invoice c where c.settle_nos like concat(‘%‘,m.settle_no,‘%‘) ) invoice_no,
(SELECT c.code_name FROM sys_d_code c WHERE c.code_type = ‘BillStatus‘ AND c.code_code = m.valid_status)valid_status,
(SELECT c.code_name FROM sys_d_code c WHERE c.code_type = ‘invoiceStatus‘ AND c.code_code = m.invoice_status)invoice_status,
(SELECT c.code_name FROM sys_d_code c WHERE c.code_type = ‘PaymentStatus‘ AND c.code_code = m.payment_flag)payment_flag   
from ibc_comm_main m 

参考博客 : https://blog.csdn.net/qq_14852397/article/details/47167401

mysql ||

上一篇:MySQL 的主从复制


下一篇:MySQL 8.0 安装教程 步骤 (windows 64位)