diff --git a/relation_select.module b/relation_select.module
index 29cb60f..667365e 100644
--- a/relation_select.module
+++ b/relation_select.module
@@ -832,7 +832,7 @@ function relation_select_entity_get_relations($entity_type, $entity_id, $relatio
     'revision_id'
   ));
   $query->condition('fde.entity_id', $relation_ids, 'IN');
-  $query->where('!(fde.endpoints_entity_type = :entity_type AND fde.endpoints_entity_id = :entity_id)', array(
+  $query->where('NOT(fde.endpoints_entity_type = :entity_type AND fde.endpoints_entity_id = :entity_id)', array(
     ':entity_type' => $entity_type,
     ':entity_id' => $entity_id
   ));
