{
  "schema_version": 2,
  "id": "commands/zmovemember",
  "title": "ZMOVEMEMBER",
  "url": "https://redis.io/docs/latest/commands/zmovemember/",
  "summary": "Moves specified members from one sorted set to another, preserving scores. Can restrict moves to members absent from or present in the destination. Deletes the source sorted set if the last member was moved.",
  "since": "8.12.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-11-23T06:19:08-08:00",
  "page_type": "content",
  "content_hash": "810029372d43bdd7412c34680e96f0410ccf215d61c57b1a46866e03db91b937",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Atomically moves named members from the sorted set at `source` to the sorted\nset at `destination`, preserving their scores.\n\nBy default, a moved member's source score replaces its score if it already\nexists in `destination`. Use `NX` to move only members absent from the\ndestination, or `XX` to move only members already present there. A member that\ndoes not satisfy the condition stays in the source.\n\nOther destination members are retained. Redis creates `destination` only when\nneeded and deletes `source` when its last member is moved. Existing key\nexpiration times are preserved; a newly created destination has no expiration.\n\nMissing source members are skipped. Duplicates are moved only once, and moved\nmembers are returned in request order. If no requested member can move, the\ncommand returns null. When both keys name the same sorted set, it returns null\nwithout looking up the requested members.\n\nIf `source` exists and either key holds another type, the command returns a\n`WRONGTYPE` error before moving any member.\n\nIn Redis Open Source Cluster, both keys must be in the same hash slot.\nSee [multi-key operations](https://redis.io/docs/latest/develop/using-commands/multi-key-operations).\n\nUse [`ZMOVE`](https://redis.io/docs/latest/commands/zmove) to select by lowest score, highest\nscore, or score range. Use [`BZMOVE`](https://redis.io/docs/latest/commands/bzmove) to wait for\nmembers to become available."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>source</code></summary>\n\nThe key of the sorted set to move members from.\n\n</details>\n\n<details open><summary><code>destination</code></summary>\n\nThe key of the sorted set to move members to.\n\n</details>\n\n<details open><summary><code>MEMBERS num-members member [member ...]</code></summary>\n\n`MEMBERS` starts the list of names to look up in `source`. `num-members` must\nbe a positive integer, followed by exactly that many member names.\n\nThe explicit block separates member names from optional arguments. Names such\nas `NX`, `XX`, `MEMBERS`, and numeric strings remain valid members. This also\nleaves room for additional options outside the counted block.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>NX | XX</code></summary>\n\n- `NX` moves only members that do not exist in `destination`.\n- `XX` moves only members that already exist in `destination`.\n\nThe options are mutually exclusive. Specify the condition before or after the\ncomplete `MEMBERS` block. Without either option, every requested member found\nin `source` can move, whether or not it exists in `destination`.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Move a named member, skipping missing names and duplicates:\n\n\nredis> ZADD source:{example} 1 one 2 two\n(integer) 2\nredis> ZADD destination:{example} 99 two 100 retained\n(integer) 2\nredis> ZMOVEMEMBER source:{example} destination:{example} MEMBERS 3 missing two two\n1) 1) \"two\"\n   2) \"2\"\nredis> ZRANGE source:{example} 0 -1 WITHSCORES\n1) \"one\"\n2) \"1\"\nredis> ZRANGE destination:{example} 0 -1 WITHSCORES\n1) \"two\"\n2) \"2\"\n3) \"retained\"\n4) \"100\"\nredis> ZMOVEMEMBER source:{example} destination:{example} MEMBERS 1 missing\n(nil)\n\n\nCondition moves on destination membership:\n\n\nredis> ZADD source:{conditional} 1 existing 2 new\n(integer) 2\nredis> ZADD destination:{conditional} 99 existing\n(integer) 1\nredis> ZMOVEMEMBER source:{conditional} destination:{conditional} NX MEMBERS 2 existing new\n1) 1) \"new\"\n   2) \"2\"\nredis> ZSCORE source:{conditional} existing\n\"1\"\nredis> ZMOVEMEMBER source:{conditional} destination:{conditional} MEMBERS 1 existing XX\n1) 1) \"existing\"\n   2) \"1\"\nredis> ZRANGE destination:{conditional} 0 -1 WITHSCORES\n1) \"existing\"\n2) \"1\"\n3) \"new\"\n4) \"2\"\n\n\nUse option names as literal members by including them in the counted list:\n\n\nredis> ZADD source:{tokens} 1 NX 2 XX 3 MEMBERS 4 1\n(integer) 4\nredis> ZMOVEMEMBER source:{tokens} destination:{tokens} NX MEMBERS 4 NX XX MEMBERS 1\n1) 1) \"NX\"\n   2) \"1\"\n2) 1) \"XX\"\n   2) \"2\"\n3) 1) \"MEMBERS\"\n   2) \"3\"\n4) 1) \"1\"\n   2) \"4\"\n\n\nThe `NX` before `MEMBERS` is the condition. The four names in the counted\nblock are literal members, including the second `MEMBERS`."
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> | <span title=\"Not supported\">&#x274c; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n\n- [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays): an array of\n  two-element member/score arrays in request order, nested even when only one\n  member is moved. Each score is a bulk string.\n- [Nil reply](https://redis.io/docs/latest/develop/reference/protocol-spec#null-arrays): `source`\n  does not exist, none of the requested members can move, or both keys name the\n  same sorted set.\n\n**RESP3:**\n\nOne of the following:\n\n- [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays): an array of\n  two-element member/score arrays in request order, nested even when only one\n  member is moved. Each score is a double.\n- [Null reply](https://redis.io/docs/latest/develop/reference/protocol-spec#nulls): `source`\n  does not exist, none of the requested members can move, or both keys name the\n  same sorted set."
    }
  ],
  "examples": []
}
