How to return records that do not match the list of UID's from a previous query?

So this initially (and probably still is) seemed like a simple task.

I am getting a full list of UIDs from a SC based on an id on the page.

Then I’m running a query to check if any of those UIDs appear in another table, and return those that do.

What I want to do is return another query of the UIDs from the full list that DO NOT appear in the second table.

Perhaps it’s just getting late here. I thought the inverse of the second query and in the join use a NOT EQUAL instead of EQUAL - but this just doesn’t work.

Any suggestions appreciated.

Use the results from the first query and use NOT IN in the second query filters.

Thanks Teo,

Can you elaborate a little please as I think I’ve done what you are suggesting without luck. I’ve tried the following, which might be what you are suggesting:

Query1
Return all result UIDs

Query2
Match UIDs from Query1 against table2 in DB. Return results that ARE a match.

Query3
Exact same query as Query 1- Return all result UIDs with the condition NOT IN Query2

If I get 1 to 10 in Query1 and 1,2,3 in Query2 I would expect Query3 to output 4 to 10. Instead it just outputs 1 to 10.

What expression are you using in your query3 exactly?
Here’s an example that will help you understand how that works.
I have a table storing all my products and another table storing 2 ids 2 and 3.

Example 1:
Filter products table with the ids returned by a query:

Filter the ids by in and use {{query.flatten('column_name')}}

Screenshot_20

returns procducts 2 and 3 as expected.

Example 2:
Filter products table with the ids returned by a query:

Filter the ids by not in and use {{query.flatten('column_name')}}

Screenshot_22

returns procducts 1 and 4 as expected.

1 Like

Thanks as always Teo. I wasn’t aware of the ‘flatten’ query formatter being available in the Query Builder - applying this worked perfectly - I can also use this elsewhere, too! Thank you.

It was introduced in the last version. It actually does what you could do by applying both join and split formatters for the expression until now.

1 Like