Hello, i am trying to get the multiple categories on topics, example https://www.waze.com/discuss/t/trouble-installing/13068
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.
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
t.id as topic_id,
c.id as category_id,
pc.id as parent_category_id
FROM topics t
INNER JOIN categories c ON t.category_id = c.id
LEFT JOIN categories pc ON c.parent_category_id = pc.id
LIMIT 20