如何从SQLite中的分组列连接/连接字符串?

前端之家收集整理的这篇文章主要介绍了如何从SQLite中的分组列连接/连接字符串?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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
使用 Group_Concat
select Company.Name,Group_Concat(Employee.id)
from Company inner join Employee
on Company.id = Employee.Company 
group by Company.id

猜你在找的Sqlite相关文章