diff --git a/synapse/storage/databases/main/__init__.py b/synapse/storage/databases/main/__init__.py index e6d35e0708..5b9e3eba68 100644 --- a/synapse/storage/databases/main/__init__.py +++ b/synapse/storage/databases/main/__init__.py @@ -261,7 +261,7 @@ class DataStore( sql_base = f""" FROM users as u LEFT JOIN profiles AS p ON u.name = '@' || p.user_id || ':' || ? - LEFT JOIN erased_users AS eu ON u.name = eu.user_id + LEFT JOIN erased_users AS eu USING(user_id) {where_clause} """ sql = "SELECT COUNT(*) as total_users " + sql_base