문제

I am writing the following query:

select c.place,a.type,group_concat(b.name) from place c
inner join menutype a
on c.id=a.id
inner join menuname b
on a.menuid=b.menuid
group by a.type

Result I am getting now is :

Place      Type      group_concat(Name)
A          Left      New Document,Vouchers
A          Top       Reports,Accounting

And I want the result like:

A     Left(New Document,Vouchers),Top(Reports,Accounting)

Kindly suggest me the way.Thank You in advance.

도움이 되었습니까?

해결책

select place, group_concat(value) from 
(select c.place, concat(a.type, '(', group_concat(b.name),')') as value from place c
inner join menutype a
on c.id=a.id
inner join menuname b
on a.menuid=b.menuid
group by a.type) tmp
group by place
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top