I have these 3 tables which put products and their categories in a N:N relationship:
products:
product_id | product_name
1 | Apples
2 | Shrimps
3 | Water
categories:
cat_id | cat_name
1 | Vegetable
2 | Seafood
3 | Fresh
4 | Drinks
5 | Non-alcohol
products_to_categories:
product_id | cat_id
2 | 2
2 | 3
3 | 3
3 | 4
3 | 5
...
I would like to SELECT CONCAT...
to have rows like this:
product_id | product_name | product_categories
2 Shrimps Seafood, Fresh
3 Water Fresh, Drinks, Non-alcohol
Is there a way to do this in MySQL?