mysql查询结果重复合并
selectprovince.name,city.name1,area.name2fromcityleftjoinprovinceoncity.provincecode=...
select province.name,city.name1,area.name2 from city left join province on city.provincecode=province.code left join area on area.citycode=city.code
查询的结果
怎么变成
name name1 name2
北京 北京 东城区,西城区,崇文区,宣武区
请高手解答!!!!!!!!! 展开
查询的结果
怎么变成
name name1 name2
北京 北京 东城区,西城区,崇文区,宣武区
请高手解答!!!!!!!!! 展开
1个回答
展开全部
用group_concat
select name,name1,group_concat(name2) from (select province.name as name,city.name1 as name1,area.name2 as name2 from city left join province on city.provincecode=province.code left join area on area.citycode=city.code) group by name,name1;
select name,name1,group_concat(name2) from (select province.name as name,city.name1 as name1,area.name2 as name2 from city left join province on city.provincecode=province.code left join area on area.citycode=city.code) group by name,name1;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询