From 38c3ddcb0179b3f8176d5f74ebf200f0b67ad924 Mon Sep 17 00:00:00 2001 From: Seamus Lee <seamuslee001@gmail.com> Date: Thu, 24 Dec 2020 07:26:49 +1100 Subject: [PATCH] dev/core#2272 Fix a DB error when merging contacts into the same household on contact export and only exporting selected contact fields --- CRM/Export/BAO/Export.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index 575aa9af24c..3f0f57a3fc2 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); -- GitLab