From: Seamus Lee Date: Wed, 23 Dec 2020 20:26:49 +0000 (+1100) Subject: dev/core#2272 Fix a DB error when merging contacts into the same household on contact... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=38c3ddcb0179b3f8176d5f74ebf200f0b67ad924;p=civicrm-core.git dev/core#2272 Fix a DB error when merging contacts into the same household on contact export and only exporting selected contact fields --- diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index 575aa9af24..3f0f57a3fc 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -438,7 +438,11 @@ VALUES $sqlValueString $relationshipJoin = $relationshipClause = ''; if (!$selectAll && $componentTable) { - $relationshipJoin = " INNER JOIN {$componentTable} ctTable ON ctTable.contact_id = {$contactA}"; + $field = 'contact_id'; + if ($componentTable === 'civicrm_contact') { + $field = 'id'; + } + $relationshipJoin = " INNER JOIN {$componentTable} ctTable ON ctTable.$field = {$contactA}"; } elseif (!empty($relIDs)) { $relID = implode(',', $relIDs);