Multiple Categories on Topics

Hello, i am trying to get the multiple categories on topics, example
when i try going into the topics table i only see 1 of the categories in this dataset, i would like to know how possible it’s to get both categories related to this topic.

Thank you in advance,

Hi Josia, welcome! :wave:

I can’t access your link, or log in. Maybe you could provide a screenshot instead?

Here as you can see there is a category and a sub-category i want to be able to see them both.

The category table contains a parent_category_id containing the ID of the parent category, or NULL if the category doesn’t have a parent. To get both categories, you probably want to LEFT JOIN to the category table a second time, something like this:

SELECT as topic_id, as category_id, as parent_category_id
FROM topics t
INNER JOIN categories c ON t.category_id =
LEFT JOIN categories pc ON c.parent_category_id =

Thank you for the help.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.