I have a MySQL table contains a list of categories.
category_id name parent_id
--------------------------------------------------
1 beverage NULL
2 Water 1
3 Sparkling Water 2
4 Snacks NULL
5 Chips 4
product_id name category_id
-------------------------------------
1 water001 3
2 Chips001 5
How can I get the category path by one query?
SELECT name as product_name,category_path FROM product_table
product_name category_path
-------------------------------------
water001 3,2,1
Chips001 5,4