I have three tables items, sizes and item_sizes for many to many relationship with join i can query this:
item size
shirt L
shirt XL
dress S
dress L
dress XL
But i want this:
item size
shirt L, XL
dress S, L, XL
Speed doesn't matter i want only the results.I can do it with while loop but is there another way of doing this query?
Answer
select item, group_concat(size)
from the_table
group by item;
More details in the manual: http://dev.mysql.com/doc/refman/5.5/en/group-by-functions.html#function_group-concat
No comments:
Post a Comment