Re: JSONB matching element count

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Arup Rakshit <aruprakshit(at)rocketmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: JSONB matching element count
Date: 2015-06-01 04:45:13
Message-ID: CAB7nPqTCXaSXZNz-1FV55Ugzc422ANcoKrugRTUNTbUJZXvabQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, May 31, 2015 at 11:07 PM, Arup Rakshit
<aruprakshit(at)rocketmail(dot)com> wrote:
> Hi,
>
> This says if matched found or not against the input array :
>
> '{"a":1, "b":2, "c":3}'::jsonb ?| array['b', 'c']
>
> But how would I determine how many matched ? Like for the above example, I see only 2 matched found.

You could use "?" to do the check for each individual key, and then
count how many matched...
--
Michael

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Noah Misch 2015-06-01 04:46:11 Re: [GENERAL] 9.4.1 -> 9.4.2 problem: could not access status of transaction 1
Previous Message Michael Paquier 2015-06-01 04:38:56 Re: replacing jsonb field value