Re: JSONB matching element count - Mailing list pgsql-general

From Michael Paquier
Subject Re: JSONB matching element count
Date
Msg-id CAB7nPqTCXaSXZNz-1FV55Ugzc422ANcoKrugRTUNTbUJZXvabQ@mail.gmail.com
Whole thread Raw
In response to JSONB matching element count  (Arup Rakshit <aruprakshit@rocketmail.com>)
List pgsql-general
On Sun, May 31, 2015 at 11:07 PM, Arup Rakshit
<aruprakshit@rocketmail.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


pgsql-general by date:

Previous
From: Michael Paquier
Date:
Subject: Re: replacing jsonb field value
Next
From: Noah Misch
Date:
Subject: Re: 9.4.1 -> 9.4.2 problem: could not access status of transaction 1