Forum Discussion

isateesh's avatar
isateesh
Contributor
7 years ago

Featured post from specific query

Hi developer community,

I'm trying to get featured post from a specific category and its ancestors.

This is the query I'm using the below:

 

SELECT id, kudos.sum(weight), post_time, conversation.featured, metrics.views, conversation.messages_count, view_href, topic.subject, kudos FROM messages WHERE conversation.featured = true AND depth=0 Order By conversation.featured ASC LIMIT 9

 

  • isateesh

    So you need to pass the category id as a constraint also. 

    SELECT id, kudos.sum(weight), post_time, conversation.featured, metrics.views, conversation.messages_count, view_href, topic.subject, kudos FROM messages WHERE category.id = 'ID' and conversation.featured = true AND depth=0 LIMIT 9

    I tried on two instances.  Order by conversation.featured = true work fine on one but it gives an error on other one instance. You may face the same issue. 
    Note(Not for all the community but it may be the issue): conversation.featured sort can only be combined with depth = 0 and conversation.featured = true in the WHERE clause. No other combinations are supported 

  • Hi Isateesh,

    Please try the following LIQL Query:

    SELECT id, kudos.sum(weight), post_time, conversation.featured, metrics.views, conversation.messages_count, view_href, topic.subject, kudos FROM messages WHERE category.id = '${id}' and conversation.featured = true AND depth=0 Order By conversation.featured ASC LIMIT 9

    • isateesh's avatar
      isateesh
      Contributor
      Thanks for quick pick Payal, will try and let you know.