JSONB arrays

From: Victor Noagbodji <vnoagbodji(at)amplify-nation(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: JSONB arrays
Date: 2018-06-28 10:28:28
Message-ID: 246BDA5E-A436-4985-91E1-D20C14C3DF00@amplify-nation.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey people,

I ended up with the following to check (or similar to return) the intersection of two list of values on a JSONB object:

array_length(
array(
select jsonb_array_elements_text(col1)
intersect
select jsonb_array_elements_text(col2)
), 1) > 0

Is there a better way?

Thanks

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Anto Aravinth 2018-06-28 10:34:07 Index Gin Creation is taking long time..
Previous Message joby.john@nccgroup.trust 2018-06-28 10:10:28 Re: Database name with semicolon