Lindsey
6 years agoLeader
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 message must have a label in the first group AND a label in the second group. However, when I run this it seems to stop after the first "in" statement, i.e. only run the part that says:
select * from messages where labels.text in ('Nursing', 'Project Manager')
Does anyone know why this is happening and if there is a way around it?
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 queryselect 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.