GROUP_CONCAT(name) 合并行,默认,分割: 1,2
FIND_IN_SET(字段名,‘1,2’)
SELECT GROUP_CONCAT(name) from dictionary_table WHERE FIND_IN_SET(code,d.transactor) GROUP BY pid
Demo
SELECT
d.id id,
d.problem_description problemDescription,
date_format(d.submission_time,'%Y-%m-%d %H:%i:%S') submissionTime,
d.submitter submitter,
d.processing_status processingStatus,
d.bug_type bugType,
(SELECT name from dictionary_table WHERE code = d.bug_type) bugTypeName,
d.bug_reason bugReason,
d.solution solution,
d.transactor transactor,
(SELECT GROUP_CONCAT(name) from dictionary_table WHERE FIND_IN_SET(code,d.transactor) GROUP BY pid) transactorName,
d.environment environment,
(SELECT name from dictionary_table WHERE code = d.environment) environmentName,
d.discovery_version discoveryVersion,
date_format(d.gmt_create,'%Y-%m-%d %H:%i:%S') gmtCreate,
date_format(d.gmt_modified,'%Y-%m-%d %H:%i:%S') gmtModified
FROM
daily d
WHERE 1=1
AND IF(#{problemDescription} is null,1=1,d.problem_description LIKE CONCAT('%',#{problemDescription},'%') )
AND IF(#{environment} is null,1=1,d.environment = #{environment})
AND IF(#{bugType} is null,1=1,d.bug_type = #{bugType})
AND IF(#{beginTime} is null,1=1,date_format(d.submission_time,'%Y-%m-%d') >= #{beginTime})
AND IF(#{endTime} is null,1=1,date_format(d.submission_time,'%Y-%m-%d') <= #{endTime})
ORDER BY
gmtModified DESC