var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Child rows concat
I was wondering if this is possible in MySQL 4.1.
I have 2 tables: Category, Products.
Each product links to a category using a foreign key.
I want to produce a query that will return the Catagory name in one column and all the product names under that category seperated by commas in the second column.
So, if Category1 has 4 products and Category2 has 2 products the output would be:
I tried playing around with CONCAT_WS and a GROUP BY on CategoryID but I think I have to have a subquery to pull out the product records for each category because the inner join method doesn't give me the right result.
Category | Products
CategoryName1 | ProductName1, ProductName2, ProductName3, ProductName4
CategoryName2 | ProductName5, ProductName6
After a day of searching, I've managed to find the solution.
MySQL has a function called GROUP_CONCAT that does just what I want.