I am trying to write a postgres sql query to select jsonb fields from my table and wondering if I can use IN statement with @> jsonb operator
The query I have is
SELECT data FROM catalog WHERE data @> '{"name":{"firstname":"myname"}}'
Above works fine with one value in WHERE condition, is it possible that I could use mutliple json in WHERE condition like along with '{"name":{"firstname":"myname"}}', I also want return records for '{"name":{"firstname":"yourname"}}'
I can do something like below
Select *
FROM catalog
WHERE data ->'name' ->> 'firstname' IN ('myname','yourname')
Whats the best way to do it ?
WHEREclause