Forum Discussion

sejago's avatar
sejago
Guide
4 years ago

Messages and Categories

I found an old post that referenced the below query:

select x, y from messages where category.id = 'z'

I have been trying to use this but judging from the documentation category.id isn't a part of 'messages so I am just wondering if something changed or am I missing something?

The aim is ultimately to get replies to topics but excludes replies from certain categories.

Any insights would be apreciated! Thanks

 

  • You can use category.id as part of the WHERE clause. For example, I was able to run this LiQL query in the API Browser (in Studio) and get the appropriate results:

    SELECT subject, view_href FROM messages WHERE category.id = 'leaf'

    You can also use an IN clause for more than one category

    SELECT subject, view_href FROM messages WHERE category.id IN ('leaf','preface') 

    and add a depth comparison if you only want replies

    SELECT subject, view_href FROM messages WHERE category.id = 'leaf' AND depth > 0

    or

    SELECT subject, view_href FROM messages WHERE category.id IN ('leaf','preface') AND depth > 0

     

  • Kevin's avatar
    Kevin
    Khoros Alumni (Retired)

    You can use category.id as part of the WHERE clause. For example, I was able to run this LiQL query in the API Browser (in Studio) and get the appropriate results:

    SELECT subject, view_href FROM messages WHERE category.id = 'leaf'

    You can also use an IN clause for more than one category

    SELECT subject, view_href FROM messages WHERE category.id IN ('leaf','preface') 

    and add a depth comparison if you only want replies

    SELECT subject, view_href FROM messages WHERE category.id = 'leaf' AND depth > 0

    or

    SELECT subject, view_href FROM messages WHERE category.id IN ('leaf','preface') AND depth > 0