sqlServer
SELECT subject_type,
stuff((select ','+subject_title from sjycxy_subject
where c.subject_type=subject_type for xml path('')),1,1,'') as subject_title
from sjycxy_subject s group by s.subject_type
<!--sqlServer -->
mysql
SELECT subject_type,single_or_many,subject_username,
GROUP_CONCAT(subject_title SEPARATOR ';'),
FROM sjycxy_subject GROUP BY subject_type;
sjycxy_subject 表名
subject_type 条件字段
subject_title 需要合并的字段
注意:两个语句有差别,分别是不同的数据库