Merging two advanced queries with OR logic

I have two queries that show me all the DONE todo blocks that are either on the current page (today’s journal date) or that reference today’s journal date)

#+BEGIN_QUERY
{
:title [:h3 “DONE”]
:query [:find (pull ?b [*])
:in $ ?current ?day ?next
:where

[?p :block/name ?current]
[?b :block/refs ?p]
[?b :block/page ?page]
[?b :block/marker “DONE”]

]
:inputs [:current-page :today :+1d]

:breadcrumb-show? false
:group-by-page? false
}
#+END_QUERY

#+BEGIN_QUERY
{:title [:h3 “ALSO DONE”]
:query [:find (pull ?b [*])
:in $ ?current ?day ?next
:where
[?b :block/page ?p]
[?b :block/marker “DONE”]
(between ?b ?day ?next)
]
:inputs [:current-page :today :+1d]
:breadcrumb-show? false
:group-by-page? false
}
#+END_QUERY

Both of these work but I would rather it all be one Advanced Query that asks is it on the current page or does it reference the current day. All my attempts to use OR logic for [?p :block/name ?current] or (between ?b ?day ?next) don’t work because I can’t have OR logic that mixes mix ?p and ?b.

Anyway to merge these into one clean Advanced Query?

1 Like

just in case it could be useful. Today I managed to kind of merge to queries. Maybe the way I use the or-join operator in this post could help you.

I tried to looking through the code on your thread but I am bit lost. Still not sure how to merge these two functions.

I rewrote the default next query

This should be pretty close to what you’re trying to achieve.
Let me know if you need further assistance!