i could write a sql query but is there a way to do this search from the UI?


Since sql is probably your best bet, the sql is pretty straight forward.

SELECT c.display_name, 
FROM   civicrm_group_contact gc,
       civicrm_contact c,
       civicrm_group g
where  gc.contact_id = c.id
and    gc.group_id = g.id
and    gc.status = 'Added'
group by 1
having count(*) = 1
| improve this answer | |

If you're trying to count the number of groups each contact is in (and select only those with a single group) then to SQL you shall go!

| improve this answer | |
  • yes, but your solution makes the assumption that all contacts belong to one or more groups – Donald Lobo May 27 '15 at 5:14
  • I edited my answer down following Lobo's comment. Its not reasonable (although it might actually be possible) to use the Custom Search Include/Exclude to complete this task. – Eliot Mason May 27 '15 at 19:24

I think you'll have to model this as a custom search (i.e. embed your sql query in a custom search). Not sure if your description includes smart groups, in which case the problem is a bit more complicated.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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