我有下表:
|animal | name |
|----------------|
|dog | Fido |
|----------------|
|dog | Spot |
|----------------|
|dog | Lassie |
|----------------|
|cat | Sue |
|----------------|
|cat | Ace |
|----------------|
|cat | Felix |
|----------------|
|pig | Porky |
|----------------|
|pig | Arnold |
|----------------|
我需要一个将返回以下内容的SQL查询
dog | Fido, Spot, Lassie
cat | Sue, Ace, Felix
pig | Porky, Arnold
答案 0 :(得分:2)
select animal, group_concat(name)
from your_table
group by animal