diff --git a/modules/Vtiger/models/Module.php b/modules/Vtiger/models/Module.php
index b716f580144c28cb488b66010f3a2200b09a30d7..fca0b98c7286a23ab7abb8f190830ad5eb7da59d 100644
--- a/modules/Vtiger/models/Module.php
+++ b/modules/Vtiger/models/Module.php
@@ -1441,7 +1441,7 @@ class Vtiger_Module_Model extends Vtiger_Module {
 				$sql = "SELECT vtiger_crmentity.crmid FROM vtiger_crmentity";
 				if($tablename == 'vtiger_crmentityrel'){
 					$sql .= " INNER JOIN $tablename ON ($tablename.relcrmid = vtiger_crmentity.crmid OR $tablename.crmid = vtiger_crmentity.crmid)
-						WHERE ($tablename.crmid IN (".  generateQuestionMarks($recordIds).")) OR ($tablename.relcrmid IN (".  generateQuestionMarks($recordIds)."))";
+						WHERE ($tablename.crmid IN (".  generateQuestionMarks($recordIds).") OR $tablename.relcrmid IN (".  generateQuestionMarks($recordIds)."))";
 					foreach ($recordIds as $key => $recordId) {
 						array_push($params, $recordId);
 					}