查询多个查询结果集合结果以逗号分隔
+----------+----+--------------------------+
| locus | id | journal |
+----------+----+--------------------------+
| AB086827 | 1 | Unpublished |
| AB086827 | 2 | Submitted (20-JUN-2002) |
| AF040764 | 23 | Unpublished |
| AF040764 | 24 | Submitted (31-DEC-1997) |
+----------+----+--------------------------+
语句 SELECT locus,GROUP_CONCAT(id) FROM info WHERE locus IN('AB086827','AF040764') GROUP BY locus; 的返回结果为
+----------+------------------+
| locus | GROUP_CONCAT(id) |
+----------+------------------+
| AB086827 | 1,2 |
| AF040764 | 23,24 |
+----------+------------------+
查询结果以逗号分隔的字符串
find_in_set 常在where后,或者返回第几位
select
allExam.*,(select group_concat(sub.name) from sys_subject sub where find_in_set(sub.id,allExam.ids))
from
(select exam.*,group_concat(exsub.ss_id)as ids from ex_exam exam left join ex_exam_subject exsub on exsub.exm_id = exam.id) allExam