Question

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.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top