Given table_a like this:
id | name
----+------
1 | aaaa
2 | bbbb
3 | cccc
I can obviously issue the following query:
SELECT * FROM table_a WHERE name IN ('aaaa', 'bbb');
But given table_b like this:
id | data
----+------------------
1 | {"name": "aaaa"}
2 | {"name": "bbbb"}
3 | {"name": "cccc"}
How do I issue a query "give me all the rows where the value of the key name is contained in this list of values?"
I know I can use the jsonb operator @> to check for each combination, but unfortunately I'd have to issue as many queries as the number of values I want to check against. Is there a way to do it in one query?
UPDATE:
I found a solution right away:
select * from table_b where data #>> '{name}' IN ('aaaa', 'bbb');