- Author: [[Roam Hacks]] - Full Title: How to Query in Roam - Tags:: [[Roam Research]] - URL: https://roamhacks.com/how-to-query-roam/ - ### Highlights first synced by [[Readwise]] [[2020-12-08]] - “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: [[2020-01-01]] [[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)) - {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: [[2020-01-01]] [[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/14808043)) - 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: [[2020-01-01]] [[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: [[2020-01-01]] [[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)) - 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: [[2020-01-01]] [[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. Let’s try this. If you want to find all blocks in your whole database linking to the page Singapore you would do this: ([View Highlight](https://instapaper.com/read/1367064120/14808069)) - 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: [[2020-01-01]] [[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))