select a.t_applypersondocno,a.t_id from sx_fms_taskinfo a
结果集
![](http://dl.iteye.com/upload/attachment/0073/3737/60591fe4-3bd2-3a3c-ae94-389f4a872cb7.jpg)
数据表 团组和国家关联表
select * from sx_fms_taskinfoid_countryid
结果集
![](http://dl.iteye.com/upload/attachment/0073/3739/afe4feba-44f5-363a-8424-f4b2f31dca74.jpg)
数据表 国家信息表
select c_id,c_name from sx_fms_countryinfo
结果集
![](http://dl.iteye.com/upload/attachment/0073/3741/896d3fd1-37f0-3036-b129-a3d072a843a2.jpg)
进行关联后将出访国家组合到一起(组合前)
select taskinfo.t_applypersondocno, countryinfo.c_name from sx_fms_taskinfo taskinfo left join sx_fms_taskinfoid_countryid tcinfo on taskinfo.t_id = tcinfo.t_id left join sx_fms_countryinfo countryinfo on tcinfo.c_id = countryinfo.c_id
组合前
![](http://dl.iteye.com/upload/attachment/0073/3743/be4196c7-9a55-3025-861e-ecae4d3371bf.jpg)
进行关联后将出访国家组合到一起(组合后) 使用了 group_concat(c_name)
select taskinfo.t_applypersondocno,group_concat(c_name) from sx_fms_taskinfo taskinfo left join sx_fms_taskinfoid_countryid tcinfo on taskinfo.t_id = tcinfo.t_id left join sx_fms_countryinfo countryinfo on tcinfo.c_id = countryinfo.c_id group by taskinfo.t_applypersondocno
组合后
![](http://dl.iteye.com/upload/attachment/0073/3745/6f46b50d-9f7f-3499-8fb2-b3d2e4be087e.jpg)