title: set-returning functions are not allowed in WHERE Postgres
body: <p>I am trying to do a join between 2 jsonb array in 2 different tables. The id to link them are inside the arrays. </p>
  
  <p>This is what I have tried, I created a function on postgres that return me a list of Id (from table B) and I am trying to match them to Table A.</p>
  
  <pre><code>TableA
  ID | resultA 
  1  | {records:[{id: 1, key: A, value: High}, {id: 2, key: B, value:Low}]}
  
  TableB
  ID | resultB
  2  | {records:[{key: A, value: New Equipment}, {key: B, value: Old Equipment}]
  </code></pre>
  
  <p>So I got the SQL to show me 2 columns for both the Ids</p>
  
  <pre><code>select elem-&gt; 'key' as TableA_id from TableA, lateral jsonb_array_elements(resultA -&gt; 'records') elem
  where elem-&gt; 'key' in (public.myfunction('999'))
  </code></pre>
  
  <p>I am facing the following error:  set-returning functions are not allowed in WHERE</p>
  
  <p>Not sure what is wrong here.</p>