I need to get a comma separated list of ids as a field for a messy third party api :s This is a simplified version of what I am trying to achieve.
| id | name |
|====|======|
| 01 | greg |
| 02 | paul |
| 03 | greg |
| 04 | greg |
| 05 | paul |
SELECT name, {some concentration function} AS ids
FROM table
GROUP BY name
Returning
| name | ids |
|======|============|
| greg | 01, 03, 04 |
| paul | 02, 05 |
I know MySQL has the CONCAT_GROUP function and I was hoping to solve this problem without installing more functions because of the environment. Maybe I can solve this problem using an OVER statement?
string_agg
orarray_agg
is available there. – Genarogendarme