Answers.Body: <p>Future searchers, here is the query I used. <strong>Your mileage may vary</strong> as this was helpful for our particular case but you may need to tweak to make it work in yours. This makes no attempt to look at membership-related contributions or anything else, simply swaps membership owner ID.</p>
  
  <p>In our case we had Households that owned the membership and shared it to Individuals by relationship. This code finds all Current, Primary Household-owned memberships that also have secondary relationships, then swaps the individual's contact ID into the primary membership's owner ID field.</p>
  
  <pre><code>UPDATE civicrm_membership primary_memb 
  
  -- Join to Household Contact
  INNER JOIN civicrm_contact hh 
  ON primary_memb.contact_id = hh.id
  
  -- Join to Individual (secondary) membership by primary membership ID
  INNER JOIN civicrm_membership indiv_memb 
  ON indiv_memb.owner_membership_id = primary_memb.id
  
  -- Join to Individual Contact
  INNER JOIN civicrm_contact indiv
  ON indiv.id = indiv_memb.contact_id
  
  -- Change owner of primary membership
  SET primary_memb.contact_id = indiv.id
  
  -- Status ID of 2 means "Current"
  WHERE primary_memb.status_id = 2
  -- Make sure it is a primary membership
  AND primary_memb.owner_membership_id IS NULL
  -- Only do this for the Household-owned memberships
  AND hh.contact_type = 'Household';
  </code></pre>
  
  <p>Next step for us is to <a href="https://civicrm.stackexchange.com/questions/4703/how-can-i-regenerate-memberships-shared-by-relationship/7252#7252">purge all secondary/shared memberships and then regenerate them</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-28T02:49:10.743Z
Answers.LastActivityDate: 2015-10-28T02:49:10.743Z
Answers.LastEditDate: 2017-04-13T12:53:13.167Z
Answers.UserDisplayName: Laryn
Answers.Body: <p>This would probably depend on how many you have. If just a few, you should be able to just change contact_id value in civicrm_membership</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-28T02:37:48.360Z
Answers.Text: Thanks, @petednz, I am going forward with this approach (ie. simply changing the contact_id value in civicrm_membership) as these memberships are largely free and I don't have to worry too much about related contributions, etc. However we have a few hundred so I am going to try to write a bit of SQL to do the deed. Fingers crossed!
Answers.UserDisplayName: Laryn
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-23T20:00:44.373Z
Answers.LastActivityDate: 2015-10-23T20:00:44.373Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>We have a database where some memberships were attached to Households and some to Individuals. We'd like to normalize this -- what is the best way to move the membership from one to another? (e.g. take a Household's membership and move it to an Individual)</p>
  
Tags: <civimember>
Title: Moving a membership from one contact type to another
ThreadText: # Moving a membership from one contact type to another
  
  (Asked by: username_0 on 2015-10-23)
  
  We have a database where some memberships were attached to Households and some to Individuals. We'd like to normalize this -- what is the best way to move the membership from one to another? (e.g. take a Household's membership and move it to an Individual)
  
  **Tags:** civimember
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-10-28. Score: 1 | Accepted answer
  
  Future searchers, here is the query I used. **Your mileage may vary** as this was helpful for our particular case but you may need to tweak to make it work in yours. This makes no attempt to look at membership-related contributions or anything else, simply swaps membership owner ID.
  
  In our case we had Households that owned the membership and shared it to Individuals by relationship. This code finds all Current, Primary Household-owned memberships that also have secondary relationships, then swaps the individual's contact ID into the primary membership's owner ID field.
  
  ```
  UPDATE civicrm_membership primary_memb 
  
  -- Join to Household Contact
  INNER JOIN civicrm_contact hh 
  ON primary_memb.contact_id = hh.id
  
  -- Join to Individual (secondary) membership by primary membership ID
  INNER JOIN civicrm_membership indiv_memb 
  ON indiv_memb.owner_membership_id = primary_memb.id
  
  -- Join to Individual Contact
  INNER JOIN civicrm_contact indiv
  ON indiv.id = indiv_memb.contact_id
  
  -- Change owner of primary membership
  SET primary_memb.contact_id = indiv.id
  
  -- Status ID of 2 means "Current"
  WHERE primary_memb.status_id = 2
  -- Make sure it is a primary membership
  AND primary_memb.owner_membership_id IS NULL
  -- Only do this for the Household-owned memberships
  AND hh.contact_type = 'Household';
  
  ```
  
  Next step for us is to [purge all secondary/shared memberships and then regenerate them](https://civicrm.stackexchange.com/questions/4703/how-can-i-regenerate-memberships-shared-by-relationship/7252#7252).
  
  
  ---
  
  ### Answer by username_1 on 2015-10-23. Score: 3
  
  This would probably depend on how many you have. If just a few, you should be able to just change contact\_id value in civicrm\_membership
  
  > **Comments:**
  > **username_0**: Thanks, @username_1, I am going forward with this approach (ie. simply changing the contact_id value in civicrm_membership) as these memberships are largely free and I don't have to worry too much about related contributions, etc. However we have a few hundred so I am going to try to write a bit of SQL to do the deed. Fingers crossed!  
  
  ---
  
  