CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Unexpected search results with Search Builder - NOT IN operator?
Pages: [1]

Author Topic: Unexpected search results with Search Builder - NOT IN operator?  (Read 305 times)

welly

  • I’m new here
  • *
  • Posts: 29
  • Karma: 2
  • CiviCRM version: 4.4
  • CMS version: Drupal
  • MySQL version: 5.1
  • PHP version: 5.3
Unexpected search results with Search Builder - NOT IN operator?
March 26, 2015, 12:19:13 am
Hello all,

The civicrm data set I'm working with has many thousands of spam contacts that I'm trying to delete. I'm trying to return users that don't belong to a particular group.

I've set up my search criteria as follows:

Quote
Include contacts where:
Contacts | Contact Type | = | Individual
Contacts | Group(s) | != | AGM Group

CivCRM shows the query as:

Code: [Select]
Contact Type - 'Individual' ...AND...
Contacts != AGM Group AND Group Status - "Added"

Yet this returns users in the AGM Group.

Changing the search to:

Quote
Include contacts where:
Contacts | Contact Type | = | Individual
Contacts | Group(s) | IN | AGM Group

CiviCRM returns the search results and shows the query as:

Code: [Select]
Contact Type - 'Individual' ...AND...
Contacts IN AGM Group AND Group Status - "Added"

The results are correct for this. There does not appear to be a NOT IN operator which I believe should in theory return the desired results. Does anyone have any suggestions?

I want to return users NOT in a group or a number of groups, who I can then delete.

Thanks!

welly

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Unexpected search results with Search Builder - NOT IN operator?
March 26, 2015, 07:09:44 am
Hi Welly,

Easiest way to do this is probably to skip Search Builder.  Create a group of all your contacts ("All Contacts") then use the custom search "Include/Exclude by Group/Tag" to include "All Contacts" and exclude the group in question.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

welly

  • I’m new here
  • *
  • Posts: 29
  • Karma: 2
  • CiviCRM version: 4.4
  • CMS version: Drupal
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Unexpected search results with Search Builder - NOT IN operator?
March 26, 2015, 10:53:58 pm
Thanks kindly, Jon! I'll try that out.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Unexpected search results with Search Builder - NOT IN operator?

This forum was archived on 2017-11-26.