Answers.Body: <p>The following SQL will show you the offending records:-</p>
  <pre><code>SELECT * FROM www_civicrm.civicrm_uf_match
  where uf_id in 
  (SELECT uf_id FROM www_civicrm.civicrm_uf_match
  group by uf_id
  having count(*)&gt;1)
  </code></pre>
  <p>This should give a list such as:-</p>
  <pre><code>id, domain_id, uf_id, uf_name, contact_id, language
  '667', '1', '180', 'email@example.com', '1234', NULL
  '668', '1', '182', 'email@example2.com', '1235', NULL
  '669', '1', '180', 'email2@example.com', '1236', NULL
  '670', '1', '182', 'email2@example2.com', '1237', NULL
  </code></pre>
  <p>So in this case we looked at the User and Contact records (using the Email and Contact ID) to find which one had logged in recently, or made a contribution, event reg, etc.... and removed the ones with older records.</p>
  <p>Another option is to update this table with the correct UF_ID and ContactID if the records are valid.</p>
  <p><strong>Please backup your DB when deleting the offending records via SQL.</strong></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-24T17:10:12.817Z
Answers.LastActivityDate: 2024-01-24T17:15:31.830Z
Answers.LastEditDate: 2024-01-24T17:15:31.830Z
Answers.UserDisplayName: Darren
Answers.Body: <p>I think the big question is going to be <em>how</em> you got duplicate uf_ids and how to prevent it from happening. How many duplicates are you seeing? The only fix I can think of is to manually remove the duplicates, but manual database changes can be a little risky. If there are just a few of them, then try to identify the &quot;right&quot; one, and delete the other one. If there are loads of them, I'd say look for a pattern and go from there. In any case, it will probably need to be a manual database fix. Sorry this is sort of a vague answer!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-24T16:27:18.057Z
Answers.Text: There is the "CiviCRM WordPress Member Sync" ( https://github.com/christianwach/civicrm-wp-member-sync )  installed and configured, is it possible there is something not quite right with it?
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-01-24T16:03:02.040Z
Answers.LastActivityDate: 2024-01-24T16:03:02.040Z
Answers.UserDisplayName: zip
Body: <p>Wordpress 6.4.2, CiviCRM 5.69.2
  Have got the &quot;You have multiple records with the same uf_id in civicrm_uf_match. You need to manually fix this in the database so that uf_id is unique&quot; but the &quot;Learn More&quot; link (<a href="https://docs.civicrm.org/sysadmin/en/latest/upgrade/todo/#todo" rel="nofollow noreferrer">https://docs.civicrm.org/sysadmin/en/latest/upgrade/todo/#todo</a>) leads to a non-existing page.</p>
  <p>There are duplicates indeed ( checked using the query below ). But what is the best course of action here?</p>
  <pre><code>SELECT uf_id, COUNT(*) AS record_count
  FROM civicrm_uf_match
  GROUP BY uf_id
  HAVING COUNT(*) &gt; 1;
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-24T16:13:26.513Z
Comments.Text: Seeing this in the latest ESR. We're looking into it and will report back with a, hopefully helpful, answer.
Comments.UserDisplayName: Darren
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-24T16:27:23.017Z
Comments.Text: There is the "CiviCRM WordPress Member Sync" ( https://github.com/christianwach/civicrm-wp-member-sync )  installed and configured, is it possible there is something not quite right with it?
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-24T17:11:49.677Z
Comments.Text: We are on Drupal 10 so it's defo data related. We do have member sync installed installed. There is an issue here which could be related: https://lab.civicrm.org/dev/core/-/issues/4500
Comments.UserDisplayName: Darren
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-01-25T11:00:34.543Z
Comments.Text: @Darren I think this comment deserves to be the answer. And the answer with SQL code piece is perfect as useful comment ;-)
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-12-18T21:31:31.243Z
Comments.Text: As for the "learn more" link pointing to a 404, there's now an issue for that: https://lab.civicrm.org/dev/core/-/issues/5650
Comments.UserDisplayName: TwoMice
Tags: <database>
Title: Duplicate records in UFMatch
ThreadText: # Duplicate records in UFMatch
  
  (Asked by: username_0 on 2024-01-22)
  
  Wordpress 6.4.2, CiviCRM 5.69.2
  Have got the "You have multiple records with the same uf_id in civicrm_uf_match. You need to manually fix this in the database so that uf_id is unique" but the "Learn More" link (https://docs.civicrm.org/sysadmin/en/latest/upgrade/todo/#todo) leads to a non-existing page.
  There are duplicates indeed ( checked using the query below ). But what is the best course of action here?
  SELECT uf_id, COUNT(*) AS record_count
  FROM civicrm_uf_match
  GROUP BY uf_id
  HAVING COUNT(*) > 1;
  
  **Tags:** database
  
  > **Comments:**
  > **username_1**: Seeing this in the latest ESR. We're looking into it and will report back with a, hopefully helpful, answer.  
  > **username_0**: There is the "CiviCRM WordPress Member Sync" ( https://github.com/christianwach/civicrm-wp-member-sync )  installed and configured, is it possible there is something not quite right with it?  
  > **username_1**: We are on Drupal 10 so it's defo data related. We do have member sync installed installed. There is an issue here which could be related: https://lab.civicrm.org/dev/core/-/issues/4500  
  > **username_0**: @username_1 I think this comment deserves to be the answer. And the answer with SQL code piece is perfect as useful comment ;-)  
  > **username_2**: As for the "learn more" link pointing to a 404, there's now an issue for that: https://lab.civicrm.org/dev/core/-/issues/5650  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2024-01-24. Score: 2 | Accepted answer
  
  The following SQL will show you the offending records:-
  SELECT * FROM www_civicrm.civicrm_uf_match
  where uf_id in 
  (SELECT uf_id FROM www_civicrm.civicrm_uf_match
  group by uf_id
  having count(*)>1)
  
  This should give a list such as:-
  id, domain_id, uf_id, uf_name, contact_id, language
  '667', '1', '180', 'email@example.com', '1234', NULL
  '668', '1', '182', 'email@example2.com', '1235', NULL
  '669', '1', '180', 'email2@example.com', '1236', NULL
  '670', '1', '182', 'email2@example2.com', '1237', NULL
  
  So in this case we looked at the User and Contact records (using the Email and Contact ID) to find which one had logged in recently, or made a contribution, event reg, etc.... and removed the ones with older records.
  Another option is to update this table with the correct UF_ID and ContactID if the records are valid.
  Please backup your DB when deleting the offending records via SQL.
  
  
  ---
  
  ### Answer by username_3 on 2024-01-24. Score: 1
  
  I think the big question is going to be *how* you got duplicate uf\_ids and how to prevent it from happening. How many duplicates are you seeing? The only fix I can think of is to manually remove the duplicates, but manual database changes can be a little risky. If there are just a few of them, then try to identify the "right" one, and delete the other one. If there are loads of them, I'd say look for a pattern and go from there. In any case, it will probably need to be a manual database fix. Sorry this is sort of a vague answer!
  
  > **Comments:**
  > **username_0**: There is the "CiviCRM WordPress Member Sync" ( https://github.com/christianwach/civicrm-wp-member-sync )  installed and configured, is it possible there is something not quite right with it?  
  
  ---
  
  