我想获得一个仅给出成员名称的组及其成员列表(仅显示一次):
表_a:
| GROUP_ID | NAME |
---------------------
| 1 | Tom |
| 2 | Frank |
| 3 | Shilla |
| 1 | Scully |
| 3 | Scully |
| 3 | Scully |
| 3 | Scully |
| 4 | Scully |
| 1 | Jen |
表_b:
| ID | GROUP_NAME |
-------------------
| 1 | Troopers |
| 2 | Clubs |
| 3 | Mavericks |
| 4 | Tomatoes |
这是SQLFidlle
这是结果:
| GROUP_NAME | GROUP_CONCAT(C.NAME) |
--------------------------------------------
| Mavericks | Scully,Scully,Scully,Shilla |
| Tomatoes | Scully |
| Troopers | Scully,Jen,Tom |
我想得到的是
| GROUP_NAME | GROUP_CONCAT(C.NAME) |
-------------------------------------
| Mavericks | Scully,Shilla |
| Tomatoes | Scully |
| Troopers | Scully,Jen,Tom |
我应该如何更改查询?