I have a field with JSON files like this:
"{\"names\":[\"James\",\"Bob\",\"Kate\",\"Tim\",\"Jerald\",\"Massimo\",\"Drake\",\"Ellen\"],\"country\":[\"Usa\",\"Montenegro\",\"Turkey\",\"Spain\"]}"
I want to get only those rows where this field in the country includes 'USA'. So I tried to write smth like this:
select *
from table
where json_field :: jsonb @> '{"country":"USA"}'::jsonb == True
However, my interpreter states that
message [ERROR: type "jsonb" does not exist]
Maybe there is another way how to check for the value in postgres?
Also tried this
json_field->'country' @> '"USA"'
But this returns this
message [ERROR: operator does not exist: json @> unknown
json_field :: jsonb? (and usejson_field::jsonb) ?Susanyou also get a match... (if your database is case insensitive)