Find path for nested categories in MySQL

This tutorial shows how to find the entire path from root to child for nested category and subcategory. We have a tables in such a way it contains unlimited level of categories and we have another column in the same table which holds the entire path for the nested categories.
Create a table


Dump some data into the table


Create procedure which will update the field cat_path using the category path


Usage Example



find path in hierarchical categories

That’s all. Thanks for your reading. Please do not forget to leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.