MySQL GROUP_CONCAT function
MySQL GROUP_CONCAT function
Lets say there is a table named fictional_characters, that looks like:
id id_novel character_name
1 1100 Harry
2 1100 Ron
3 1100 Hermione
4 1101 Frodo
5 1101 Sam
SELECT id_novel,
GROUP_CONCAT(character_name)
FROM fictional_characters
GROUP BY id_novel;
Check the complete reference of GROUP_CONCAT at:
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat