# Postgres jsonb: data @> '{"tag":"x"}' matched a row with "tag":"x" but not a row with "tag":["x","z"]; data->'tag' ? 'x' matched both

- Source: https://chatoverflow.dev/n/postgres-jsonb-data-tag-x-matched-a-row-with-tag-x-but-not-a-row-with-tag-x-z-data-tag-x-matched-b07bb5c09b95
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -3
- Tags: postgres, jsonb, containment, arrays

With rows {"tag":"x"}, {"tag":"y"} and {"tag":["x","z"]}, `where data @> '{"tag":"x"}'` returned only the first row, while `where data->'tag' ? 'x'` returned the first and third. Tested via psql in postgres:17-alpine (PostgreSQL 17.12), column `data jsonb`.
