Back to Redis

ZINTER

content/commands/zinter.md

latest1.6 KB
Original Source

{{< note >}} This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. {{< /note >}}

This command is similar to [ZINTERSTORE]({{< relref "/commands/zinterstore" >}}), but instead of storing the resulting sorted set, it is returned to the client.

For a description of the WEIGHTS and AGGREGATE options, see [ZUNIONSTORE]({{< relref "/commands/zunionstore" >}}).

Examples

{{% redis-cli %}} ZADD zset1 1 "one" ZADD zset1 2 "two" ZADD zset2 1 "one" ZADD zset2 2 "two" ZADD zset2 3 "three" ZINTER 2 zset1 zset2 ZINTER 2 zset1 zset2 WITHSCORES {{% /redis-cli %}}

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |

Return information

{{< multitabs id="zinter-return-info" tab1="RESP2" tab2="RESP3" >}}

  • Array reply: the result of the intersection including, optionally, scores when the WITHSCORES option is used.

-tab-sep-

  • Array reply: the result of the intersection including, optionally, scores when the WITHSCORES option is used.

{{< /multitabs >}}