开发者

return a list from different rows into a single field

I have the following table:

|animal | name   |
|----------------|
|dog    | Fido   |
|----------------|
|dog    | Spot   |
|----------------|
|dog    | Lassie |
|----------------|
|cat    | Sue    |
|----------------|
|cat    | Ace    |
|----------------|
|cat    | Felix  |
|----------------|
|pig    | Porky  |
|----------------|
|pig    | Arnold |
|----------------开发者_开发问答|

I need an SQL query that will return the following

dog | Fido, Spot, Lassie
cat | Sue, Ace, Felix
pig | Porky, Arnold


select animal, group_concat(name)
from your_table
group by animal
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜