# SUNION

> Return the members present in any of the given sets.

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

```
SUNION key [key ...]
```

- Group: Set
- Complexity: O(N) where N is the total number of members in all given sets
- HotKV Cloud: all plans
- On-Premise: no license needed

`SUNION` returns the union of the given sets: every member that appears in at
least one of them, once. Missing keys count as empty sets. To store the result,
use [SUNIONSTORE](https://docs.hotkv.com/commands/sunionstore/index.md).

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Success | Array of bulk strings (empty if all keys are missing) | Set of bulk strings |

`SUNION` replies with a `WRONGTYPE` error if any of the keys holds a value that
is not a set.

## Examples

```
127.0.0.1:6379> SADD a "x" "y"
(integer) 2
127.0.0.1:6379> SADD b "y" "z"
(integer) 2
127.0.0.1:6379> SUNION a b
1) "x"
2) "y"
3) "z"
```

The order of members in the reply is not defined.

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[SUNIONSTORE](https://docs.hotkv.com/commands/sunionstore/index.md), [SINTER](https://docs.hotkv.com/commands/sinter/index.md), [SDIFF](https://docs.hotkv.com/commands/sdiff/index.md),
[ZUNION](https://docs.hotkv.com/commands/zunion/index.md)