# SINTERCARD

> Count the members of the intersection of sets, optionally stopping at a limit.

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

```
SINTERCARD numkeys key [key ...] [LIMIT limit]
```

- Group: Set
- Complexity: O(N*M) worst case, where N is the size of the smallest set and M is the number of sets
- HotKV Cloud: all plans
- On-Premise: no license needed

`SINTERCARD` returns how many members the intersection of the given sets
would have, without building or returning it. With `LIMIT`, counting stops
once `limit` common members are found, which is cheaper when you only need to
know whether the intersection reaches a threshold. A missing key counts as an
empty set, so the result is `0`.

## Options

| Option | Effect |
| --- | --- |
| `numkeys` | How many keys follow. Must be at least 1. |
| `LIMIT limit` | Stop counting at `limit`. `0` (the default) means no limit. Can be repeated; the last one counts. |

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Success | Integer: the size of the intersection, capped at `limit` | Same |

Errors:

- `ERR numkeys should be greater than 0` if `numkeys` is not a positive
  integer.
- `ERR Number of keys can't be greater than number of args` if fewer keys
  follow than `numkeys` says.
- `ERR LIMIT can't be negative` if the limit is negative or not an integer.
- `ERR syntax error` for anything else after the keys.
- `WRONGTYPE` if any key holds a value that is not a set.

## Examples

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

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[SINTER](https://docs.hotkv.com/commands/sinter/index.md), [SCARD](https://docs.hotkv.com/commands/scard/index.md), [ZINTERCARD](https://docs.hotkv.com/commands/zintercard/index.md)