# ZREM

> Remove one or more members from a sorted set.

URL: https://docs.hotkv.com/commands/zrem/

```
ZREM key member [member ...]
```

- Group: Sorted set
- Complexity: O(M*log(N)) where M is the number of members removed and N is the size of the sorted set
- HotKV Cloud: all plans
- On-Premise: no license needed

`ZREM` removes each `member` from the sorted set stored at `key`. Members that
are not present are ignored. When the last member is removed, the key is
deleted.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Success | Integer: the number of members removed | Same |
| Key does not exist | Integer `0` | Same |

`ZREM` replies with a `WRONGTYPE` error if `key` holds a value that is not a
sorted set.

## Examples

```
127.0.0.1:6379> ZADD board 100 "alice" 90 "bob"
(integer) 2
127.0.0.1:6379> ZREM board "bob" "nobody"
(integer) 1
127.0.0.1:6379> ZRANGE board 0 -1
1) "alice"
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[ZADD](https://docs.hotkv.com/commands/zadd/index.md), [ZREMRANGEBYSCORE](https://docs.hotkv.com/commands/zremrangebyscore/index.md),
[ZREMRANGEBYRANK](https://docs.hotkv.com/commands/zremrangebyrank/index.md), [ZPOPMIN](https://docs.hotkv.com/commands/zpopmin/index.md)