Reference a query from a query

I have two queries in a note. I’d like to make it so that the second query excludes everything that the first query displays. How would i do this?

You haven’t shown an example of what you’re trying to do, so I’m not 100% sure. If you include a more specific example, it will be easier for people to give specific advice.

But I ask you, why do you think the queries should communicate with each other? The 2nd query doesn’t need to reference the first query in any way. But in the 2nd query, you’ll have to include the negative logic of the first query.

Example:

Query 1:
Show all tasks about goats
Query 2:
Show all tasks about carrots MINUS all tasks about goats
(no need to have any knowledge about Query 1.)

But for actual Dataview syntax, I think we need to know what your intended query is. Otherwise we are just guessing.

this worked. but i have a different problem now. how do i exclude notes that have two specified tags. i found that to exclude notes with a tag i’d use -#mytag but i want to exclude notes that have two tags. i tried -#mytag AND -#mytag2 but this excludes notes that have at least one of those tags but i want it to exclude only when it has BOTH tags.

Again, that is missing the full example.

So anyone who wants to help will just be guessing and writing example syntax out of context.

Can you please show a full example of the query you’re trying to do?

Also, is that Dataview or the built-in query that you are doing?

the first query currently is

LIST
FROM #myTag1 AND #myTag2

the second one is

LIST
FROM [[]] AND -#myTag1 AND -#myTag2

the problem that i have is that the 2nd query excludes notes that contain either #myTag1 or #myTag2 but i want to to exclude only notes that contain both of those tags.

1 Like

To reverse the #myTag1 AND #myTag2 the easiest way is usually !(#myTag1 AND #myTag2). If that can’t be done, or you don’t like the look of it, you need to flip it all around using boolean negation, and turn the expression into (-#myTag1 OR -#myTag2).

1 Like