Answers.Body: <p>The 'Include/Exclude' search is very handy for situations like this:</p>
  
  <ol>
  <li>create a group of all contacts of interest</li>
  <li>create a group of those who DO meet some criteria</li>
  <li>use include/exclude to include group 1 and exclude group 2 to
  produce those who DON'T meet the criteria</li>
  </ol>
  
  <p>So in your case:</p>
  
  <ol>
  <li>create a group of all people </li>
  <li>create a group who do have a relationship (Advanced Search, open Relationships section, select relationship types of interest, search, save group)</li>
  <li>go to <code>Search &gt; Custom Searches &gt; Include/Exclude search</code>  include your 'all' group, exclude the 'has relationship' group (select either AND/OR - doesn't matter since you are not using tags but it is still required)  Save as a group if you want.</li>
  </ol>
  
  <p>If you want to use this often, create all 3 groups as smart groups.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-08T09:09:50.780Z
Answers.LastActivityDate: 2018-11-08T09:09:50.780Z
Answers.UserDisplayName: Aidan
Answers.Body: <p>While this isn't an ideal fix, it's a quick one if you know SQL:</p>
  
  <ul>
  <li>Create a new group called "Contacts without relationship".</li>
  <li>Note the group ID.  You can find the group id by hovering the mouse over the "Contacts" link of the group on the <strong>Contacts » Manage Groups</strong> page.  In the screenshot below, you can see that the group ID of "Summer Program Volunteers" is "3".</li>
  <li>Run this SQL statement:
  <code>
  INSERT INTO civicrm_group_contact (group_id, contact_id) (SELECT '3', cc.id from civicrm_contact cc LEFT JOIN civicrm_relationship cr ON cc.id = cr.contact_id_a WHERE cr.id IS NULL AND cc.is_deleted = 0 AND cc.id IN (SELECT cc.id from civicrm_contact cc LEFT JOIN civicrm_relationship cr ON cc.id = cr.contact_id_b WHERE cr.id IS NULL AND cc.is_deleted = 0));
  </code></li>
  </ul>
  
  <p>Replace the "3" above with YOUR group ID before you run it.</p>
  
  <p>Now, everyone without a relationship will be in your group.</p>
  
  <p>Screenshot for group ID (click to zoom):
  <a href="https://i.sstatic.net/2J7iv.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2J7iv.png" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-08T00:46:54.937Z
Answers.Text: Nice, although is it missing an INSERT? I might also add cc.is_deleted = 0 to both the main and subqueries. And possibly restrict it to ACTIVE relationships, which might even require comparing end_date to the current date.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-08T01:01:02.203Z
Answers.Text: Oops - yeah, I modified then forgot to add the INSERT.  I'll try to tweak this.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-08T09:50:30.137Z
Answers.Text: Thank you - I don't know SQL, but someone else in our group might.
Answers.UserDisplayName: Cozy4907
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-08T00:25:37.407Z
Answers.LastActivityDate: 2018-11-08T01:02:53.283Z
Answers.LastEditDate: 2018-11-08T01:02:53.283Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>One way is to export two lists to Excel and then use the power of Excel to find the missing ones.</p>
  
  <ol>
  <li>Under Reports - Contact Reports, run the Relationship Report and under Columns check "Contact ID" so that it appears in the output.</li>
  <li>From the Actions dropdown export that to CSV.</li>
  <li>Under Reports - Contact Reports, run the Constituent Summary Report and under Columns check "Contact ID".</li>
  <li>From the Actions dropdown export that to CSV.</li>
  <li>Do something like described here to find the contact ids that are in the second list but not the first. Note you'll need to sort the lists by contact id first for this method to work.
  <a href="https://www.extendoffice.com/documents/excel/3124-excel-compare-two-columns-for-missing-values.html#formula" rel="nofollow noreferrer">https://www.extendoffice.com/documents/excel/3124-excel-compare-two-columns-for-missing-values.html#formula</a></li>
  </ol>
  
  <p>There are other ways to do it in Excel if you don't like that one above. Search the internet for something like "how to tell which values are missing from two lists in excel". If you're using LibreOffice or similar I'm sure it can be done too.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-07T22:33:35.810Z
Answers.LastActivityDate: 2018-11-07T22:33:35.810Z
Answers.UserDisplayName: Demerit
Answers.Body: <p>Either you can create a custom report to achieve that or can be done through CiviCRM API in a module code.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-07T21:47:56.397Z
Answers.LastActivityDate: 2018-11-07T21:47:56.397Z
Answers.UserDisplayName: Hassan Farooq
Body: <p>We're using CiviCRM to primarily build a network of activist groups around the country. There are "area organisers" and people they are linked with. We are using the relationship function to link people together. 
  It would be really helpful to be able to search for people who haven't yet been linked to an area organiser (because there isn't one yet in their locality), but I can only work out how to search for relationships between specific individuals. Is there a way to search for everyone who doesn't yet have a relationship with anyone else in the database?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-15T10:02:45.103Z
Comments.Text: I love the the title of your question 
Comments.UserDisplayName: William Mortada
Tags: <search><relationships>
Title: Searching for someone not in a relationship
ThreadText: # Searching for someone not in a relationship
  
  (Asked by: username_0 on 2018-11-07)
  
  We're using CiviCRM to primarily build a network of activist groups around the country. There are "area organisers" and people they are linked with. We are using the relationship function to link people together.
  It would be really helpful to be able to search for people who haven't yet been linked to an area organiser (because there isn't one yet in their locality), but I can only work out how to search for relationships between specific individuals. Is there a way to search for everyone who doesn't yet have a relationship with anyone else in the database?
  
  **Tags:** search, relationships
  
  > **Comments:**
  > **username_1**: I love the the title of your question   
  
  ---
  
  ## 4 answers
  
  ### Answer by username_2 on 2018-11-08. Score: 6
  
  The 'Include/Exclude' search is very handy for situations like this:
  
  1. create a group of all contacts of interest
  2. create a group of those who DO meet some criteria
  3. use include/exclude to include group 1 and exclude group 2 to
     produce those who DON'T meet the criteria
  
  So in your case:
  
  1. create a group of all people
  2. create a group who do have a relationship (Advanced Search, open Relationships section, select relationship types of interest, search, save group)
  3. go to `Search > Custom Searches > Include/Exclude search` include your 'all' group, exclude the 'has relationship' group (select either AND/OR - doesn't matter since you are not using tags but it is still required) Save as a group if you want.
  
  If you want to use this often, create all 3 groups as smart groups.
  
  
  ---
  
  ### Answer by username_3 on 2018-11-08. Score: 2
  
  While this isn't an ideal fix, it's a quick one if you know SQL:
  
  * Create a new group called "Contacts without relationship".
  * Note the group ID. You can find the group id by hovering the mouse over the "Contacts" link of the group on the **Contacts » Manage Groups** page. In the screenshot below, you can see that the group ID of "Summer Program Volunteers" is "3".
  * Run this SQL statement:
    `INSERT INTO civicrm_group_contact (group_id, contact_id) (SELECT '3', cc.id from civicrm_contact cc LEFT JOIN civicrm_relationship cr ON cc.id = cr.contact_id_a WHERE cr.id IS NULL AND cc.is_deleted = 0 AND cc.id IN (SELECT cc.id from civicrm_contact cc LEFT JOIN civicrm_relationship cr ON cc.id = cr.contact_id_b WHERE cr.id IS NULL AND cc.is_deleted = 0));`
  
  Replace the "3" above with YOUR group ID before you run it.
  
  Now, everyone without a relationship will be in your group.
  
  Screenshot for group ID (click to zoom):
  [![enter image description here](https://i.sstatic.net/2J7iv.png)](https://i.sstatic.net/2J7iv.png)
  
  > **Comments:**
  > **username_4**: Nice, although is it missing an INSERT? I might also add cc.is_deleted = 0 to both the main and subqueries. And possibly restrict it to ACTIVE relationships, which might even require comparing end_date to the current date.  
  > **username_3**: Oops - yeah, I modified then forgot to add the INSERT.  I'll try to tweak this.  
  > **username_0**: Thank you - I don't know SQL, but someone else in our group might.  
  
  ---
  
  ### Answer by username_4 on 2018-11-07. Score: 2
  
  One way is to export two lists to Excel and then use the power of Excel to find the missing ones.
  
  1. Under Reports - Contact Reports, run the Relationship Report and under Columns check "Contact ID" so that it appears in the output.
  2. From the Actions dropdown export that to CSV.
  3. Under Reports - Contact Reports, run the Constituent Summary Report and under Columns check "Contact ID".
  4. From the Actions dropdown export that to CSV.
  5. Do something like described here to find the contact ids that are in the second list but not the first. Note you'll need to sort the lists by contact id first for this method to work.
     <https://www.extendoffice.com/documents/excel/3124-excel-compare-two-columns-for-missing-values.html#formula>
  
  There are other ways to do it in Excel if you don't like that one above. Search the internet for something like "how to tell which values are missing from two lists in excel". If you're using LibreOffice or similar I'm sure it can be done too.
  
  
  ---
  
  ### Answer by username_5 on 2018-11-07. Score: 0
  
  Either you can create a custom report to achieve that or can be done through CiviCRM API in a module code.
  
  
  ---
  
  