- This is a block that is connected to [[Project A]].
- Here is a Task that is relevant to this project, but it's not directly tagged with :
- TODO Write Stuff down
- On the other hand here is a Task that is tagged with the project:
- TODO Do Stuff
- TODO And here is a unrelated Task that should not be found
I can’t figure out a query that finds TODO Write Stuff down and TODO Do Stuff - both Tasks are somehow connected to Project A or aren’t they?
- Meeting notes
- TODO aaaa
- bbbbb
- TODO ccccc
- dddddd
- TODO eeeee
- <query here - would return all three TODOs>
Ideally the query wouldn’t need to change depending on the title of the block (that way I can just paste in the query as part of my meeting template and see all the actions at the end of the meeting)
Would love any help you could provide!!
Since it was featured in Logseq Times, I’ll just add to this post to say I’m a dumdum and there is an attribute for this, making the query A LOT simpler!
This is for the query based on page reference, not the one based on parent blocks.
#+BEGIN_QUERY
{:title ["Query by page & alias"]
:query [:find (pull ?b [*])
:in $ ?page
:where
[?b :block/marker "TODO"]
[?p :block/name ?page]
(or-join [?b ?p]
[?b :block/path-refs ?p]
(and
[?p :block/alias ?a]
[?b :block/path-refs ?a]
)
)
]
:result-transform :sort-by-priority
:table-view? false
:inputs [:query-page] ; alternatively use the lower-case name of a page.
}
#+END_QUERY
This query uses :block/path-refs to find all references in all parent blocks, including the block itself.
As opposed to :block/refs which only looks at the references of the block itself.
Thanks so much again for your help @Siferiax, your work is amazing!!
I’m sure this is covered before, but I’m struggling to find an answer to the below two questions:
I’d like to create a query that returns all TODOs wherever “abc” is included in a tag, until now I’ve been defaulting to the below but feel like there’s a more efficient way to write this:
I’m trying to create a query like the above but only include the TODO if it has a scheduled or deadline included (and then list from most urgent to least urgent)
Again sorry if these answers already exist somewhere!!
Could it be possible to also include tasks from the (sub-)pages themselves?
I put the query on the page “work”. It finds all my tasks from my Journal (and other) pages that include [[work]], e.g. TODO [[work/my project]] Do something
Can the query be modified that it also displays tasks that are on the page [[work/my project]]?