具有
Company id Name 1 Enron 2 Walmart Employee id Company 2 1 3 1 4 2 5 2 6 2
我想要
Enron 2,3 Walmart 4,5,6到目前为止,我写道:
select Company.Name, Employee.id
from Company inner join Employee
on Company.id = Employee.Company
group by Company.id
但目前的结果是
Enron 2 Walmart 4
答案 0 :(得分:31)
使用Group_Concat:
select Company.Name, Group_Concat(Employee.id)
from Company inner join Employee
on Company.id = Employee.Company
group by Company.id