Hi,
I've a table where there are bits of data I want to group together as such:
----------------
|id |name | val |
----------------
|1 |test | 2 |
----------------
|2 |test | 10 |
----------------
|3 |test | 8 |
----------------
I want to group by the name column and have the val colum be return as a comma separated list as follows:
---------------
|name| val |
---------------
|test | 2,10,8|
---------------
is there a function that could do that in MYSQL without writing an SP...
Any help would be much appreciated.
Steve
NB:
Thanks to someone on another forum I've found a solution.
For anybody else who may have the same problem look up GROUP_CONCAT()
In the above instance I used the follow query:
SELECT name, GROUP_CONCAT(val)
FROM table
GROUP BY name