I’m not sure what this is called but it happens all the time that you get a resultset like:
(id,name,age,favorite)
0,John Smith,21,Pepperoni
1,John Smith,21,Ham
2,John Smith,21,Olives
3,John Doe,54,Tomatoes
4,John Doe,54,Potatoes
Now when you’re iterating over this resultset, how can you concat the last column on rows that have similar name and ages? To get a result like John Smith,21,"Pepperoni,Ham,Olives". And what is this action called in general? I’m using JDBC-MySQL if that matters.
Thanks
This action could be done with GROUP_CONCAT in MySQL :
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat
Be careful, GROUP_CONCAT is only in MySQL and not a standard SQL.
You could not do that in other DBMS with a query.