I have a view with FILTER CRITERIA set. I have three groups, each joined by ANDs, with the criteria within each group ORed. The final group are two taxonomy terms, meaning I want my query to return nodes that have one term or the other. No node will have both of the tags set.

enter image description here enter image description here

However, when I see the SQL in the preview, the terms seem are connected by a AND. enter image description here

WHERE (((node__field_event_categories.field_event_categories_target_id = '434')) AND ((node__field_event_categories2.field_event_categories_target_id = '212'))) AND ((taxonomy_index.status = '1') AND (((DATE_FORMAT((node__field_date_range.field_date_range_value + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2018-10-22T04:00:00' + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s'))) OR ((DATE_FORMAT((node__field_date_range.field_date_range_end_value + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2018-10-22T04:00:00' + INTERVAL -14400 SECOND), '%Y-%m-%d\T%H:%i:%s')))))

This causes my query not to return any results.

I've tried removing each tid, one by one, and when one is missing I get results. So I'm thinking I should get both sets of results when they are set to OR.

To make sure I was reading the SQL correctly, I ran it through a pretty-printer:

enter image description here

To double check, I exported the views config, to see what the yaml said about the WHERE clause, and it all seems to be OR within the groups:

enter image description here

I even re-imported the configuration from this yaml, but I still get the same results.

How can I get my taxonomy criteria to function using OR?

Edit In the course of troubleshooting, I tried to simplify the filter criteria. I removed everything, all groups and criteria. This is what I have now:

enter image description here

enter image description here

enter image description here

This is Drupal 8.6.2. We just updated, so I'm wondering if this is a new bug.


1 Answer 1


This answer on a related (perhaps duplicate?) issue provided settings that got the display working for me.

First, on each filter criteria, check "Reduce Duplicates".

EDIT Actually, the answer I linked says to uncheck the "DISTINCT" in the Advanced settings for the query. However, when I did that, I got duplicates. I unchecked it, and I got the right number of results. So that second step may not be necessary for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.