# How to Query in Roam

URL:: https://roamhacks.com/how-to-query-roam/
Author:: roamhacks.com
## Highlights
> “Query” searches for specific blocks (not pages!) across your whole database that match your search criteria. ([View Highlight](https://instapaper.com/read/1367064120/14808034))
> {and: [[tagA]] [[tagB]]}Find blocks containing both tagA and tagB{or: [[tagA]] [[tagB]]}Find blocks containing tagA or tagB (or both){not: [[tagA]] [[tagB]]}Find blocks that have neither tagA nor tagB{between: [[January 1st, 2020]] [[today]]}Find blocks that have dates between 1 Jan 2020 and the day that the query is run (ie it keeps “up to date”).
> Note: You can only use [[today]] on the DAILY NOTES page ([View Highlight](https://instapaper.com/read/1367064120/14808039))
> Self-reference
> Queries search your whole database, including the query block itself. This means that often your query will return itself in its results, which can be annoying. So to avoid this, it’s common to turn the query function into a link to a page by enclosing it in square brackets (ie [[query]]), then exclude that page by adding {not: [[query]]} like so:
> Before: {{query: {and:[[Singapore]] [[London]]} }}
> After: {{[[query]]: {and:[[Singapore]] [[London]] {not:[[ ([View Highlight](https://instapaper.com/read/1367064120/14808055))
> There are 4 logical words you can use to increase the specificity of what you’re looking for. These words are called operators and are AND, OR, NOT, and BETWEEN.
> {and: [[tagA]] [[tagB]]}Find blocks containing both tagA and tagB{or: [[tagA]] [[tagB]]}Find blocks containing tagA or tagB (or both){not: [[tagA]] [[tagB]]}Find blocks that have neither tagA nor tagB{between: [[January 1st, 2020]] [[today]]}Find blocks that have dates between 1 Jan 2020 and the day that the query is run (ie it keeps “up to date”).
> Note: You can only use [[today]] on the DAILY NOTES page. ([View Highlight](https://instapaper.com/read/1367064120/14808064))
> {and: [[tagA]] [[tagB]]}Find blocks containing both tagA and tagB{or: [[tagA]] [[tagB]]}Find blocks containing tagA or tagB (or both){not: [[tagA]] [[tagB]]}Find blocks that have neither tagA nor tagB{between: [[January 1st, 2020]] [[today]]}Find blocks that have dates between 1 Jan 2020 and the day that the query is run (ie it keeps “up to date”). ([View Highlight](https://instapaper.com/read/1367064120/14808065))
> and: [[tagA]] [[tagB]]}Find blocks containing both tagA and tagB{or: [[tagA]] [[tagB]]}Find blocks containing tagA or tagB (or both){not: [[tagA]] [[tagB]]}Find blocks that have neither tagA nor tagB{between: [[January 1st, 2020]] [[today]]}Find blocks that have dates between 1 Jan 2020 and the day that the query is run (ie it keeps “up to date”).
> Note: You can only use [[today]] on the DAILY NOTES page. ([View Highlight](https://instapaper.com/read/1367064120/14808073))
---
Title: How to Query in Roam
Author: roamhacks.com
Tags: readwise, articles
date: 2024-01-30
---
# How to Query in Roam

URL:: https://roamhacks.com/how-to-query-roam/
Author:: roamhacks.com
## AI-Generated Summary
None
## Highlights
> “Query” searches for specific blocks (not pages!) across your whole database that match your search criteria. ([View Highlight](https://instapaper.com/read/1367064120/14808034))
> {and: [[tagA]] [[tagB]]}Find blocks containing both tagA and tagB{or: [[tagA]] [[tagB]]}Find blocks containing tagA or tagB (or both){not: [[tagA]] [[tagB]]}Find blocks that have neither tagA nor tagB{between: [[January 1st, 2020]] [[today]]}Find blocks that have dates between 1 Jan 2020 and the day that the query is run (ie it keeps “up to date”).
> Note: You can only use [[today]] on the DAILY NOTES page ([View Highlight](https://instapaper.com/read/1367064120/14808039))
> Self-reference
> Queries search your whole database, including the query block itself. This means that often your query will return itself in its results, which can be annoying. So to avoid this, it’s common to turn the query function into a link to a page by enclosing it in square brackets (ie [[query]]), then exclude that page by adding {not: [[query]]} like so:
> Before: {{query: {and:[[Singapore]] [[London]]} }}
> After: {{[[query]]: {and:[[Singapore]] [[London]] {not:[[ ([View Highlight](https://instapaper.com/read/1367064120/14808055))
> There are 4 logical words you can use to increase the specificity of what you’re looking for. These words are called operators and are AND, OR, NOT, and BETWEEN.
> {and: [[tagA]] [[tagB]]}Find blocks containing both tagA and tagB{or: [[tagA]] [[tagB]]}Find blocks containing tagA or tagB (or both){not: [[tagA]] [[tagB]]}Find blocks that have neither tagA nor tagB{between: [[January 1st, 2020]] [[today]]}Find blocks that have dates between 1 Jan 2020 and the day that the query is run (ie it keeps “up to date”).
> Note: You can only use [[today]] on the DAILY NOTES page. ([View Highlight](https://instapaper.com/read/1367064120/14808064))
> {and: [[tagA]] [[tagB]]}Find blocks containing both tagA and tagB{or: [[tagA]] [[tagB]]}Find blocks containing tagA or tagB (or both){not: [[tagA]] [[tagB]]}Find blocks that have neither tagA nor tagB{between: [[January 1st, 2020]] [[today]]}Find blocks that have dates between 1 Jan 2020 and the day that the query is run (ie it keeps “up to date”). ([View Highlight](https://instapaper.com/read/1367064120/14808065))
> and: [[tagA]] [[tagB]]}Find blocks containing both tagA and tagB{or: [[tagA]] [[tagB]]}Find blocks containing tagA or tagB (or both){not: [[tagA]] [[tagB]]}Find blocks that have neither tagA nor tagB{between: [[January 1st, 2020]] [[today]]}Find blocks that have dates between 1 Jan 2020 and the day that the query is run (ie it keeps “up to date”).
> Note: You can only use [[today]] on the DAILY NOTES page. ([View Highlight](https://instapaper.com/read/1367064120/14808073))