My current query:-
select
p.id as product_id,
p.product_name,
child.name as category_name,
parent.name as parent_category_name
from category child
left join products p on FIND_IN_SET(child.id,p.category_ids)
left join category parent on parent.id = child.parentid and parent.parentid = 0
where p.id = 7
Current Results:-
product_Id | product_name | category_name | parent_category_name
7 ponds cream chemical
7 ponds medicine chemical
7 ponds powder Ayurvedic
Now I would like to group by product id and the child/parent category should be show in comma separated format like "cream,medicine,powder". So here the number of record would be only one like this :-
Expected Results:-
product_Id | product_name | category_name | parent_category_name
7 ponds cream,medicine,powder chemical,chemical,Ayurvedic
I don't know its possible or not in mysql query.
Any suggestion or ideas would be greatly appreciated.
Thanks a lot.