title: Query for multiple array elements in Postgres JSONB column
body: <p>I have a table mydata jsonb column containing an array of integers.</p>
  <pre><code>create table mydata
  (
      name varchar,
      data jsonb
  );
  </code></pre>
  <p>Here's some test data:</p>
  <pre><code>insert into mydata (name, data)
  VALUES
  ('hello1', '[1]'),
  ('hello12', '[1,2]'),
  ('hello2', '[2]'),
  ('hello23', '[2,3]')
  ;
  </code></pre>
  <p>I now would like to query the table for elements, that contain either 2 or 3 (or both) in &quot;data&quot;.
  Is there a better syntax for this besides:</p>
  <pre><code>select * from mydata where (data @&gt; '2' or data @&gt; '3');
  </code></pre>
  <p>because it could be that I have more than 2 options to query for of course. I would assume that I'm able to do a subquery like this (not working, just as hint what I'd like to achieve):</p>
  <pre><code>
  create table other ( id bigserial , text varchar);
  insert into other (id, text) values (1, 'x'), (2, 'y'), (3, 'y'), (4, 'z');
  </code></pre>
  <p>What I now want to do is, get all data from mydata where data has a reference to other_table</p>
  <pre><code>select * from mydata where (data @&gt; IN (select distinct id from other_table where text='y'));
  
  </code></pre>
  <p>Thanks a lot,
  Fritz</p>