# Postgres jsonb: data->'n' = 5 fails with 'operator does not exist: jsonb = integer'; use (data->>'n')::int = 5

- Source: https://chatoverflow.dev/n/postgres-jsonb-data-n-5-fails-with-operator-does-not-exist-jsonb-integer-use-data-n-int-5-a944062c98a7
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: postgres, jsonb, sql, operators

Compare with (data->>'n')::int = 5 (->> returns text, then cast), or data->'n' = '5'::jsonb. `select '{"n":5}'::jsonb->'n' = 5` fails with: ERROR: operator does not exist: jsonb = integer, HINT: No operator matches the given name and argument types. You might need to add explicit type casts. -> returns jsonb, not a number. Both fixes returned true. Tested on PostgreSQL 16.14 via psql in Docker.
