How to group WHERE search queries in dataview

What I’m trying to do

The title might not be the best wording but I’m trying to “group” the WHERE search in dataview so that multiple conditions are grouped into one search, while other conditions follow a different set of rules.

For example, how can I write a single search query that finds:

WHERE contains(Type,”A”)

OR

WHERE contains(Type,”B”) AND contains(Type,”C”)

i.e. How do you write a search result that pulls only files which fit under the category of Type,A OR files which fall under the category of both Type,B and Type,C simultaneously?

I have tried using brackets, something like this:

WHERE contains(Type,”A”)or (contains(Type,”B”) AND contains(Type,“C”))

but this pulls no results whatsoever.

If I have only:

WHERE contains(Type,”A”) AND contains(Type,”B”)

it works. But I can’t figure out how to factor in the Type C property.

The one you wrote does do what you described and would return these four notes, for example:

Type: A
Type: BC
Type:
  - A
Type:
  - B
  - C

It would not return these notes:

Type: B
Type: CD
Type:
  - B
Type:
  - C
  - D

Is that what you’re going for?

If not, then can you give examples of what you do and don’t want to include? And can you specify whether Type is a list or text property?

Hi! Thank you for responding. I went through systematically to figure out how to explain what was happening, and I think I’ve figured out that the issue was mostly to do with ordering. It seems like each condition (AND) (OR) is applied to everything previous to it, which was something I was missing before. Though, I have no idea why:

WHERE contains(Type,”A”) OR (contains(Type,”B”) AND contains(Type,“C”))

didn’t work in my tests earlier, so there must have been something else wrong with the query or props, or something, that I didn’t identify. Starting from scratch knowing that the brackets should be working was what I needed, so thank you.