Running PostgresSQL v10.5.
In my table table_a
that has a column metadata
which is of type jsonb
.
It has a JSON array as one of it's keys array_key
with value something like this:
[{"key1":"value11", "key2":"value21", "key3":"value31"},
{"key1":"value21", "key2":"value22", "key3":"value23"}]
This is how I can query this key
SELECT metadata->>'array_key' from table_a
This gives me the entire array. Is there any way I can query only selected keys and perhaps format them?
The type of the array is text i.e pg_typeof(metadata->>'array_key')
is text
An ideal output would be
"value11, value13", "value21, value23"