diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py
index 10f7c7a4bc13c153becb6bcb03132d1fd24ed042..3a99dc2349198bfbc4cfaf197a5155dc450f5b03 100644
--- a/synapse/storage/roommember.py
+++ b/synapse/storage/roommember.py
@@ -266,7 +266,7 @@ class RoomMemberStore(SQLBaseStore):
             " ON m.event_id = c.event_id "
             " AND m.room_id = c.room_id "
             " AND m.user_id = c.state_key"
-            " WHERE %(where)s"
+            " WHERE c.type = 'm.room.member' AND %(where)s"
         ) % {
             "where": where_clause,
         }