1

我正在编写以下查询:

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

我现在得到的结果是:

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

我想要这样的结果:

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

请给我建议。提前谢谢你。

4

1 回答 1

1
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
于 2013-08-27T07:25:03.343 回答