Coding Tips
Joomla
Querying for a category and all it’s subcategories
Joomla nests tables using a parent_id column and lft/rgt columns to maintain the hierarchy. Here is a simple query to retrieve the category <CategoryId> and all it descendent categories.
SELECT tree.*
FROM #__categories AS tree, #__categories AS parent
WHERE tree.lft BETWEEN parent.lft AND parent.rgt AND parent.id = <CategoryId>;