Forum Discussion

Lindsey's avatar
Lindsey
Leader
6 years ago

Multiple "in" queries in REST-API

I am running into an issue where i want to run: select * from messages where labels.text in ('Nursing', 'Project Manager') and labels.text in ('Walmart', 'Sprint') That is, I want to say the mess...
  • VikasB's avatar
    6 years ago

    Lindsey 
    Seems like the same constraint cannot apply multiple times in a single query. 
    Here is a workaround but you have to go a bit long way 
    1. Get message ids using below query

    select id from messages where labels.text in ('Nursing', 'Project Manager')

    2. Run below query 

    select * from messages where labels.text in ('Walmart', 'Sprint')

     3. Compare the result lists returned by step 1 and step 2. And fetch the ids which exist in both the lists. 
    Hope it will return the expected result.