Have discovered recently while searching for multiple tags. Even if Search operator radio button AND selected, search for two tags returns results with OR logic. Mean, there is a contact, which has several tags assigned; search by selecting, say, two tags contact has, returns contacts tagged by one of tags, not both of them. Double- and triple-checked. Sounds like a bug, but not entirely sure, since no similar complains found. Will anyone with similar setup (mean, contacts with multiple tags), confirm it works / doesn't work, please.
1 Answer
I think the AND operator applies between fields, not within options of a field. If you want to search TagX AND TagY you can do this in Search Builder.
-
You're right, it's probably my misunderstanding of GUI elements placement: since AND/OR switch is located inside "Basic Criteria" fieldset, it looks so logical it covers fields inside this fieldset. I think also, help note, attached to AND/OR switch states the same: nimbus.everhelper.me/client/notes/share/428744/…– yurgMar 25, 2016 at 9:53
-
Have tried to use an API for search by tag(s); have got an error (had to cut full sql query due to comment length restriction): "no such field", "sql": "SELECT contact_a.id as contact_id ... FROM civicrm_contact contact_a LEFT JOIN civicrm_entity_tag
civicrm_entity_tag-Belgium
ON (civicrm_entity_tag-Belgium
.entity_id = contact_a.id ANDcivicrm_entity_tag-Belgium
.entity_table = 'civicrm_contact') WHERE ( contact_a.is_deleted = '0' ANDcivicrm_entity_tag-Belgium
.tag_id IN (Belgium) ) [nativecode=1054 ** Unknown column 'Belgium' in 'where clause']",– yurgMar 29, 2016 at 9:55 -
1The AND/OR was moved out of Basic Citeria in 4.7. The Search Criteria help note states: "When multiple options are selected within a search field the selections are combined using OR criteria (e.g. selecting both 'Group A' and 'Group B' will find contacts who are either in 'Group A' OR 'Group B' or in both). By default the different search fields are combined using the AND Search Operator (e.g. selecting Tag is 'Age' AND Country is 'Canada' returns only those contacts who meet both criteria). You can override the Search Operator default for combining different fields in the Search Settings."– JoAnneApr 24, 2016 at 12:40