How to Test Multiple Contains Statements in a Dataview Query?

Things I have tried

WHERE contains(Role, "Protagonist") AND !contains(Role, "Historical" AND "Secondary")

What I’m trying to do

I’m attempting to exclude characters’ from a table of my story’s protagonists that contain the word “Secondary” or “Historical.”

So, if the code was working, it would render characters who have the role “Protagonist” but not characters who have the role “Secondary Protagonist” or “Historical Protagonist.”

As you can see above, I wrote an SQL query that I thought would achieve this, but the code does not work and all the characters with “Protagonist” within their Role display (including those with “Secondary” and “Historical”).

Could anyone help me understand how to include to strings to test against ina contains statement?

Thanks!

1 Like

You can’t use “multiple” checks inside the same contains. You need to repeat it:

WHERE contains(Role, "Protagonist") AND !contains(Role, "Historical") AND !contains(Role, "Secondary")

or

WHERE containsword(Role, "Protagonist") AND !containsword(Role, "Historical") AND !containsword(Role, "Secondary")

I don’t know why but econtains() seems not to be working…

1 Like

Thank you so much. That worked!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.