diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 57643ede2677..2b0b209fd208 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -4208,6 +4208,12 @@ public function relationship(&$values) { } $sql = " CREATE TEMPORARY TABLE {$relationshipTempTable} + ( + `contact_id` int(10) unsigned NOT NULL DEFAULT '0', + `contact_id_alt` int(10) unsigned NOT NULL DEFAULT '0', + KEY `contact_id` (`contact_id`), + KEY `contact_id_alt` (`contact_id_alt`) + ) (SELECT contact_id_b as contact_id, contact_id_a as contact_id_alt, civicrm_relationship.id FROM civicrm_relationship INNER JOIN civicrm_contact c ON civicrm_relationship.contact_id_a = c.id