I have the following table and i want to generate a view. See the result. How can i achieve that? I tried with group_cat but that doesnt work :(
id product_id cat_id date
1 1 1 2018-05-01
2 1 1 2018-05-02
3 1 1 2018-05-04
4 1 1 2018-05-05
5 1 1 2018-05-06
6 1 1 2018-05-07
4 1 1 2018-05-08
5 1 1 2018-05-09
6 1 1 2018-05-10
7 1 2 2018-05-01
8 1 2 2018-05-02
9 1 2 2018-05-04
10 1 2 2018-05-05
11 1 2 2018-05-06
12 1 2 2018-05-07
13 1 2 2018-05-08
14 1 2 2018-05-09
15 1 2 2018-05-10
Result:
product_id cat_id dates
1 1 2018-05-01,2018-05-02,2018-05-03,2018-05-04,etc comma seperated
1 2 2018-05-01,2018-05-02,2018-05-03,2018-05-04,etc comma seperated
Query:
select
tmp.product_id, tmp.cat_id, group_concat(tmp.date separator ',') as dates
from xxxx as tmp
group by tmp.cat_id;