diff --git a/include/QueryGenerator/QueryGenerator.php b/include/QueryGenerator/QueryGenerator.php
index 40932b8b46d98b6756c59277dc07bc70a4e80048..5e4e13d145ba559be839d04e4f97aa71db5537dc 100644
--- a/include/QueryGenerator/QueryGenerator.php
+++ b/include/QueryGenerator/QueryGenerator.php
@@ -550,7 +550,12 @@ class QueryGenerator {
 		}
 		$ownerFields = $this->meta->getOwnerFields();
 		if (count($ownerFields) > 0) {
-			$ownerField = $ownerFields[0];
+			//there are more than one field pointing to the users table, the real one is the one called assigned_user_id if there is one, otherwise pick the first
+			if(in_array("assigned_user_id",$ownerFields)){
+				$ownerField="assigned_user_id";
+			}else{
+				$ownerField = $ownerFields[0];
+			}
 		}
 		$baseTable = $this->meta->getEntityBaseTable();
 		$sql = " FROM $baseTable ";