From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Tim Smith <randomdev4+postgres(at)gmail(dot)com> |
Cc: | Merlin Moncure <mmoncure(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: In need of some JSONB examples ? |
Date: | 2015-01-23 18:49:49 |
Message-ID: | 54C297CD.8080206@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 01/23/2015 10:15 AM, Tim Smith wrote:
>> How does it not work?
>> In other words what was the query you tried and what was the output?
>
> As in, it doesn't work. Full stop....
>
> \d+ json_test
> Table "public.json_test"
> Column | Type | Modifiers | Storage | Stats target | Description
> ---------+-------+-----------+----------+--------------+-------------
> content | jsonb | not null | extended | |
> Indexes:
> "idxgin" gin (content)
>
>
> truncate json_test;
> TRUNCATE TABLE
> insert into json_test(content) values('[{"ID": "3119","Desc":"bob"}]');
> INSERT 0 1
>
> select content->'Desc' from json_test where content @> '{"ID":"3119"}';
> ?column?
> ----------
> (0 rows)
>
WITH c AS
(SELECT
jsonb_array_elements(content) AS content
FROM
json_test)
SELECT
content->'Desc'
FROM
c
WHERE
content @> '{"ID":"3119"}'
?column?
----------
"bob"
(1 row)
With the caveats that Christophe Pettus mentioned.
>> --
>> Adrian Klaver
>> adrian(dot)klaver(at)aklaver(dot)com
>
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Suresh Raja | 2015-01-23 19:56:53 | commit inside a function failing |
Previous Message | Tim Smith | 2015-01-23 18:15:59 | Re: In need of some JSONB examples ? |