需求
diseases列中保存的是以","进行分割的id值
根据diseases中的id值,关联查询如下记录,获取name值,并将name值以","进行连接,单独作为一列
SQL语句
SELECT
h.diseases,
GROUP_CONCAT(q.`name`) AS diseasesStr
FROM
clinic_process_health h
INNER JOIN health_info_question q ON (
FIND_IN_SET(q.id, h.diseases) > 0
)
GROUP BY
h.id;