Basically the question is how to get from this:
foo_id foo_name 1 A 1 B 2 C
to this:
foo_id foo_name
1 A B
2
The result is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024 characters, so we first do:
SET group_concat_max_len=100000000;
and then, for example:
SELECT pub_id,GROUP_CONCAT(cate_id SEPARATOR ' ') FROM book_mast GROUP BY pub_id