Forum Discussion

hlio's avatar
hlio
Mentor
9 years ago
Solved

LiQL question about selecting from ancestor category

Hello I'm trying to select the top 5 TKB articles with a specific label, but only within our Japan Category not our English category.

 

I'm not sure how to include the ancestor_categories.id field when pulling from the messages table, and I don't believe the way I'm doing it below is correct.

SELECT subject, view_href FROM messages WHERE labels.text='example' AND conversation.style='tkb' AND conversation.featured = false AND ancestor_categories.id = 'Japan' ORDER BY metrics.views DESC LIMIT 5" />

 

Can anyone help out? Appreciate any quick responses our suggestions!

2 Replies

  • hlio's avatar
    hlio
    Mentor
    9 years ago

    Hi TariqHussain,

     

     

    So the Japan category is the top parent category and there are multiple subcategories within "Japan". I'm looking for all labels within Japan including all the categories underneath Japan. With your query, would that pull all the labels in the Japan category as well as the subcategories below?

     

    I thought that's why I needed to refer and use the ancestorcategory statement.

    Appreciate the help and your clarification!