Answers.Body: <p>You have to watch out using the search builder when your search involves related entities.  Searching for <code>does not equal</code> <code>X</code> on something doesn't exclude contacts with a related entity with a field's value as <code>X</code>, it searches for contacts who <em>have</em> that related entity so long as the value doesn't equal <code>X</code>.</p>
  
  <p>In other words, searching for contacts where tag name <code>does not equal</code> <code>Prospect</code> doesn't exclude all prospects; it finds all contacts with tags so long as those tags aren't <code>Prospect</code>.</p>
  
  <p>Although it seems foreign in the context of tags, groups, and some entities, it makes lots of sense regarding addresses: if you search for people where the state <code>does not equal</code> <code>Alabama</code>, it'll exclude people who <strong>only</strong> have an address in Alabama, but it'll include people who live in Alabama but have a work address in Georgia.</p>
  
  <p>To reliably exclude contacts, you either need a specialized search like the include/exclude search, or you need to run a search with the criteria you want to <em>include</em> on, tag those contacts, run a search with the criteria you want to <em>exclude</em> on, and remove the tag from those contacts.</p>
  
  <p>For example, to find everyone in Baltimore who <em>has not</em> attended an event in the past year, run a search (Advanced Search is easiest) for everyone in Baltimore, and use the "Actions" drop-down to tag all the results with a new tag called "Baltimore - no events".  Then, run a search for participants at events in the past year, and use the "Actions" drop-down to untag all the results, removing the "Baltimore - no events" tag.  (It doesn't matter that your second search will catch people in Glen Burnie or whatever who never had the tag in the first place.)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-09T05:35:13.363Z
Answers.LastActivityDate: 2016-01-09T05:35:13.363Z
Answers.UserDisplayName: Andie Hunt
Answers.Body: <p>I got around the problem by using the Include/Exclude search eventually. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-08T17:54:52.837Z
Answers.LastActivityDate: 2016-01-08T17:54:52.837Z
Answers.UserDisplayName: Matt
Body: <p>We're trying to set up a search that includes contacts with one tag but excludes ones with another tag. Yet the "does not equal" operator does not appear to be functioning. Any ideas what the issue could be?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-08T16:16:36.710Z
Comments.Text: What version of CiviCRM, what platform, and what search mechanism? Are you using the Search Builder?
Comments.UserDisplayName: choster
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-08T16:19:45.467Z
Comments.Text: CiviCRM 4.6, Joomla and yes, using the SEarch builder.
Comments.UserDisplayName: Matt
Tags: <search><search-builder>
Title: "does not equal" operator not working
ThreadText: # "does not equal" operator not working
  
  (Asked by: username_0 on 2016-01-08)
  
  We're trying to set up a search that includes contacts with one tag but excludes ones with another tag. Yet the "does not equal" operator does not appear to be functioning. Any ideas what the issue could be?
  
  **Tags:** search, search-builder
  
  > **Comments:**
  > **username_1**: What version of CiviCRM, what platform, and what search mechanism? Are you using the Search Builder?  
  > **username_0**: CiviCRM 4.6, Joomla and yes, using the SEarch builder.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2016-01-09. Score: 4
  
  You have to watch out using the search builder when your search involves related entities. Searching for `does not equal` `X` on something doesn't exclude contacts with a related entity with a field's value as `X`, it searches for contacts who *have* that related entity so long as the value doesn't equal `X`.
  
  In other words, searching for contacts where tag name `does not equal` `Prospect` doesn't exclude all prospects; it finds all contacts with tags so long as those tags aren't `Prospect`.
  
  Although it seems foreign in the context of tags, groups, and some entities, it makes lots of sense regarding addresses: if you search for people where the state `does not equal` `Alabama`, it'll exclude people who **only** have an address in Alabama, but it'll include people who live in Alabama but have a work address in Georgia.
  
  To reliably exclude contacts, you either need a specialized search like the include/exclude search, or you need to run a search with the criteria you want to *include* on, tag those contacts, run a search with the criteria you want to *exclude* on, and remove the tag from those contacts.
  
  For example, to find everyone in Baltimore who *has not* attended an event in the past year, run a search (Advanced Search is easiest) for everyone in Baltimore, and use the "Actions" drop-down to tag all the results with a new tag called "Baltimore - no events". Then, run a search for participants at events in the past year, and use the "Actions" drop-down to untag all the results, removing the "Baltimore - no events" tag. (It doesn't matter that your second search will catch people in Glen Burnie or whatever who never had the tag in the first place.)
  
  
  ---
  
  ### Answer by username_0 on 2016-01-08. Score: 1
  
  I got around the problem by using the Include/Exclude search eventually.
  
  
  ---
  
  