Answers.Body: <p>An activity gets recorded when you merge and it looks up the target contact via that.</p>
  
  <p>Use <code>$winnerContact = civicrm_api3('Contact', 'getmergedto', ['contact_id' =&gt; $contactId])</code>.</p>
  
  <p>See also <a href="https://github.com/civicrm/civicrm-core/blob/5.20.2/api/v3/Contact.php#L1275" rel="noreferrer">https://github.com/civicrm/civicrm-core/blob/5.20.2/api/v3/Contact.php#L1275</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-16T22:12:59.790Z
Answers.Text: Awesome! Thank you very much
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-16T20:44:33.887Z
Answers.LastActivityDate: 2019-12-16T20:44:33.887Z
Answers.UserDisplayName: Demerit
Body: <p>After Merging Contacts -> dig up a Contact in the Trash bin and you'll see something like:</p>
  
  <p><a href="https://i.sstatic.net/dbQ8w.png" rel="noreferrer"><img src="https://i.sstatic.net/dbQ8w.png" alt="enter image description here"></a></p>
  
  <p>Where does CiviCRM store this information? How does it track which Contact is merged with which Contact?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-12-16T19:27:40.227Z
Comments.Text: I can see an activity in the merged record, but I doubt that's what CiviCRM is using here. I looked in all the tables like "%log%" to no avail.
Comments.UserDisplayName: Alan Dixon
Tags: <contacts><duplicate-contacts>
Title: Where does CiviCRM store Merge 'history'?
ThreadText: # Where does CiviCRM store Merge 'history'?
  
  (Asked by: username_0 on 2019-12-16)
  
  After Merging Contacts -> dig up a Contact in the Trash bin and you'll see something like:
  
  [![enter image description here](https://i.sstatic.net/dbQ8w.png)](https://i.sstatic.net/dbQ8w.png)
  
  Where does CiviCRM store this information? How does it track which Contact is merged with which Contact?
  
  **Tags:** contacts, duplicate-contacts
  
  > **Comments:**
  > **username_1**: I can see an activity in the merged record, but I doubt that's what CiviCRM is using here. I looked in all the tables like "%log%" to no avail.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-12-16. Score: 6 | Accepted answer
  
  An activity gets recorded when you merge and it looks up the target contact via that.
  
  Use `$winnerContact = civicrm_api3('Contact', 'getmergedto', ['contact_id' => $contactId])`.
  
  See also <https://github.com/civicrm/civicrm-core/blob/5.20.2/api/v3/Contact.php#L1275>
  
  > **Comments:**
  > **username_0**: Awesome! Thank you very much  
  
  ---
  
  